2024-02-10 11:59:58 +00:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"log"
|
|
|
|
|
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/client"
|
|
|
|
"go.temporal.io/sdk/worker"
|
|
|
|
)
|
|
|
|
|
|
|
|
func main() {
|
2024-02-16 12:07:29 +00:00
|
|
|
config := config.NewConfig()
|
2024-02-13 21:39:34 +00:00
|
|
|
|
2024-02-10 11:59:58 +00:00
|
|
|
// Initialize a Temporal Client
|
|
|
|
// Specify the Namespace in the Client options
|
|
|
|
clientOptions := client.Options{
|
2024-02-15 17:43:35 +00:00
|
|
|
HostPort: config.Temporal.ServerHost,
|
2024-02-10 11:59:58 +00:00
|
|
|
Namespace: "default",
|
|
|
|
}
|
|
|
|
temporalClient, err := client.Dial(clientOptions)
|
|
|
|
if err != nil {
|
|
|
|
log.Fatalln("Unable to create a Temporal Client", err)
|
|
|
|
}
|
|
|
|
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)
|
|
|
|
}
|
|
|
|
}
|