Documentation
¶
Index ¶
- func NewDurableTask[I, O any](opts create.StandaloneTask, ...) workflow.WorkflowDeclaration[I, O]
- func NewTask[I, O any](opts create.StandaloneTask, ...) workflow.WorkflowDeclaration[I, O]
- func NewWorkflow[I any, O any](opts create.WorkflowCreateOpts[I], client v1.HatchetClient) workflow.WorkflowDeclaration[I, O]
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewDurableTask ¶
func NewDurableTask[I, O any](opts create.StandaloneTask, fn func(ctx worker.DurableHatchetContext, input I) (*O, error), client v1.HatchetClient) workflow.WorkflowDeclaration[I, O]
NewDurableTask creates a durable task that is implemented as a simple workflow with a single task. It provides proper type inference for the input and output types.
Example:
type SimpleInput struct {
Message string
}
type SimpleOutput struct {
TransformedMessage string
}
simpleTask := v1.NewTask(v1.TaskCreateOpts[SimpleInput, SimpleOutput]{
Name: "simple-task",
Fn: func(input SimpleInput, ctx worker.DurableHatchetContext) (*SimpleOutput, error) {
return &SimpleOutput{
TransformedMessage: strings.ToLower(input.Message),
}, nil
},
}, &client)
func NewTask ¶
func NewTask[I, O any](opts create.StandaloneTask, fn func(ctx worker.HatchetContext, input I) (*O, error), client v1.HatchetClient) workflow.WorkflowDeclaration[I, O]
NewTask creates a standalone task that is implemented as a simple workflow with a single task. It provides proper type inference for the input and output types.
Example:
type SimpleInput struct {
Message string
}
type SimpleOutput struct {
TransformedMessage string
}
simpleTask := v1.NewTask(v1.TaskCreateOpts[SimpleInput, SimpleOutput]{
Name: "simple-task",
Fn: func(input SimpleInput, ctx worker.HatchetContext) (*SimpleOutput, error) {
return &SimpleOutput{
TransformedMessage: strings.ToLower(input.Message),
}, nil
},
}, &client)
func NewWorkflow ¶
func NewWorkflow[I any, O any](opts create.WorkflowCreateOpts[I], client v1.HatchetClient) workflow.WorkflowDeclaration[I, O]
NewWorkflow creates a new workflow declaration with the specified input and output types before a client is initialized. This function is used to create strongly typed workflow declarations with the given client. NOTE: This is placed on the client due to circular dependency concerns.
Types ¶
This section is empty.