2024-02-16 12:07:29 +00:00
|
|
|
package workflows
|
|
|
|
|
|
|
|
import (
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"code.tjo.space/mentos1386/zdravko/internal/activities"
|
|
|
|
"go.temporal.io/sdk/workflow"
|
|
|
|
)
|
|
|
|
|
2024-02-21 09:06:54 +00:00
|
|
|
type HealthcheckWorkflowParam struct {
|
|
|
|
Script string
|
2024-02-16 12:07:29 +00:00
|
|
|
}
|
|
|
|
|
2024-02-21 09:06:54 +00:00
|
|
|
func HealthcheckWorkflowDefinition(ctx workflow.Context, param HealthcheckWorkflowParam) error {
|
2024-02-16 12:07:29 +00:00
|
|
|
options := workflow.ActivityOptions{
|
|
|
|
StartToCloseTimeout: 10 * time.Second,
|
|
|
|
}
|
|
|
|
ctx = workflow.WithActivityOptions(ctx, options)
|
|
|
|
|
2024-02-21 09:06:54 +00:00
|
|
|
activityParam := activities.HealtcheckParam{
|
|
|
|
Script: param.Script,
|
2024-02-16 12:07:29 +00:00
|
|
|
}
|
|
|
|
|
2024-02-21 09:06:54 +00:00
|
|
|
var result *activities.HealthcheckResult
|
|
|
|
err := workflow.ExecuteActivity(ctx, activities.Healthcheck, activityParam).Get(ctx, &result)
|
2024-02-16 12:41:18 +00:00
|
|
|
if err != nil {
|
|
|
|
return err
|
|
|
|
}
|
|
|
|
|
|
|
|
return nil
|
2024-02-16 12:07:29 +00:00
|
|
|
}
|