36 lines
945 B
Go
36 lines
945 B
Go
package example
|
|
|
|
import (
|
|
"git.coopcloud.tech/wiki-cafe/member-console/internal/workflows/common"
|
|
"go.temporal.io/sdk/workflow"
|
|
)
|
|
|
|
type Input struct {
|
|
Message string
|
|
}
|
|
|
|
type Output struct {
|
|
Result string
|
|
}
|
|
|
|
// Workflow is the entry point for the example domain workflow.
|
|
func Workflow(ctx workflow.Context, input Input) (*Output, error) {
|
|
logger := workflow.GetLogger(ctx)
|
|
logger.Info("ExampleWorkflow started", "message", input.Message)
|
|
|
|
// Apply activity options
|
|
ctx = workflow.WithActivityOptions(ctx, common.DefaultActivityOptions())
|
|
|
|
// Execute activity
|
|
var activities *Activities // Pointer to the struct to get method names
|
|
var result string
|
|
err := workflow.ExecuteActivity(ctx, activities.ExampleActivity, input.Message).Get(ctx, &result)
|
|
if err != nil {
|
|
logger.Error("Activity failed", "error", err)
|
|
return nil, err
|
|
}
|
|
|
|
logger.Info("ExampleWorkflow completed", "result", result)
|
|
return &Output{Result: result}, nil
|
|
}
|