internal

package
v0.73.68 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2025 License: MIT Imports: 15 Imported by: 0

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 RunAsChildOpts struct {
	RunOpts
	Sticky *bool
	Key    *string
}

type RunOpts

type RunOpts struct {
	AdditionalMetadata *map[string]interface{}
	Priority           *int32
}

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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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