Help us shape the future of Go! Take the 2026 Go Developer Survey

factory

package
v0.77.13 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 21, 2026 License: MIT Imports: 5 Imported by: 2

Documentation

Index

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL