2024-02-10 11:59:58 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"log"
|
|
|
|
|
2024-02-16 13:50:35 +00:00
|
|
|
"code.tjo.space/mentos1386/zdravko/internal"
|
2024-02-16 12:07:29 +00:00
|
|
|
"code.tjo.space/mentos1386/zdravko/internal/activities"
|
|
|
|
"code.tjo.space/mentos1386/zdravko/internal/config"
|
|
|
|
"code.tjo.space/mentos1386/zdravko/internal/workflows"
|
2024-02-10 11:59:58 +00:00
|
|
|
"go.temporal.io/sdk/worker"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2024-02-16 13:50:35 +00:00
|
|
|
cfg := config.NewConfig()
|
2024-02-13 21:39:34 +00:00
|
|
|
|
2024-02-16 13:50:35 +00:00
|
|
|
temporalClient, err := internal.ConnectToTemporal(cfg)
|
2024-02-10 11:59:58 +00:00
|
|
|
if err != nil {
|
2024-02-16 13:50:35 +00:00
|
|
|
log.Fatal(err)
|
2024-02-10 11:59:58 +00:00
|
|
|
}
|
|
|
|
defer temporalClient.Close()
|
2024-02-13 21:39:34 +00:00
|
|
|
|
2024-02-10 11:59:58 +00:00
|
|
|
// Create a new Worker
|
2024-02-13 21:39:34 +00:00
|
|
|
// TODO: Maybe identify by region or something?
|
2024-02-16 12:07:29 +00:00
|
|
|
w := worker.New(temporalClient, "default", worker.Options{})
|
2024-02-13 21:39:34 +00:00
|
|
|
|
2024-02-10 11:59:58 +00:00
|
|
|
// Register Workflows
|
2024-02-16 12:07:29 +00:00
|
|
|
w.RegisterWorkflow(workflows.HealthcheckHttpWorkflowDefinition)
|
|
|
|
|
2024-02-10 11:59:58 +00:00
|
|
|
// Register Activities
|
2024-02-16 12:07:29 +00:00
|
|
|
w.RegisterActivity(activities.HealthcheckHttpActivityDefinition)
|
|
|
|
|
2024-02-10 11:59:58 +00:00
|
|
|
// Start the the Worker Process
|
2024-02-16 12:07:29 +00:00
|
|
|
err = w.Run(worker.InterruptCh())
|
2024-02-10 11:59:58 +00:00
|
|
|
if err != nil {
|
|
|
|
log.Fatalln("Unable to start the Worker Process", err)
|
|
|
|
}
|
|
|
|
}
|