Documentation
¶
Overview ¶
Package internal provides internal functionality for the Hatchet Go SDK
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type DurableWrappedTaskFn ¶
type DurableWrappedTaskFn func(ctx worker.DurableHatchetContext) (interface{}, error)
DurableWrappedTaskFn represents a durable task function that can be executed by the Hatchet worker. It takes a DurableHatchetContext and returns an interface{} result and an error.
type NamedFunction ¶
type NamedFunction struct {
ActionID string
Fn WrappedTaskFn
}
NamedFunction represents a function with its associated action ID
type RunAsChildOpts ¶
type TaskWithSpecificOutput ¶
type TaskWithSpecificOutput[I any, T any] struct { Name string Fn func(ctx worker.HatchetContext, input I) (*T, error) }
Define a TaskDeclaration with specific output type
type WorkflowBase ¶
type WorkflowBase interface {
// Dump converts the workflow declaration into a protobuf request and function mappings.
// Returns the workflow definition, regular task functions, durable task functions, and the on failure task function.
Dump() (*contracts.CreateWorkflowVersionRequest, []NamedFunction, []NamedFunction, WrappedTaskFn)
}
WorkflowBase defines the common interface for all workflow types.
type WorkflowDeclaration ¶
type WorkflowDeclaration[I, O any] interface { WorkflowBase // Name returns the resolved workflow name (including namespace if applicable). Name() string // Task registers a task that will be executed as part of the workflow Task(opts create.WorkflowTask[I, O], fn func(ctx worker.HatchetContext, input I) (interface{}, error)) *task.TaskDeclaration[I] // DurableTask registers a durable task that will be executed as part of the workflow. // Durable tasks can be paused and resumed across workflow runs, making them suitable // for long-running operations or tasks that require human intervention. DurableTask(opts create.WorkflowTask[I, O], fn func(ctx worker.DurableHatchetContext, input I) (interface{}, error)) *task.DurableTaskDeclaration[I] // OnFailureTask registers a task that will be executed if the workflow fails. OnFailure(opts create.WorkflowOnFailureTask[I, O], fn func(ctx worker.HatchetContext, input I) (interface{}, error)) *task.OnFailureTaskDeclaration[I] // Cron schedules the workflow to run on a regular basis using a cron expression. Cron(ctx context.Context, name string, cronExpr string, input I, opts ...v0Client.RunOptFunc) (*rest.CronWorkflows, error) // Schedule schedules the workflow to run at a specific time. Schedule(ctx context.Context, triggerAt time.Time, input I, opts ...v0Client.RunOptFunc) (*rest.ScheduledWorkflows, error) // Get retrieves the current state of the workflow. Get(ctx context.Context) (*rest.Workflow, error) // Metrics retrieves metrics for this workflow. Metrics(ctx context.Context, opts ...rest.WorkflowGetMetricsParams) (*rest.WorkflowMetrics, error) // QueueMetrics retrieves queue metrics for this workflow. QueueMetrics(ctx context.Context, opts ...rest.TenantGetQueueMetricsParams) (*rest.TenantQueueMetrics, error) }
WorkflowDeclaration represents a workflow with input type I and output type O. It provides methods to define tasks, specify dependencies, and execute the workflow.
func NewWorkflowDeclaration ¶
func NewWorkflowDeclaration[I any, O any](opts create.WorkflowCreateOpts[I], v0 v0Client.Client) WorkflowDeclaration[I, O]
NewWorkflowDeclaration creates a new workflow declaration with the specified options and client. The workflow will have input type I and output type O.
type WrappedTaskFn ¶
type WrappedTaskFn func(ctx worker.HatchetContext) (interface{}, error)
WrappedTaskFn represents a task function that can be executed by the Hatchet worker. It takes a HatchetContext and returns an interface{} result and an error.