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

task

package
v0.112.13 Latest Latest
Warning

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

Go to latest
Published: Oct 20, 2026 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type DurableTaskDeclaration

type DurableTaskDeclaration[I any] struct {
	TaskBase
	NamedTaskImpl
	TaskShared

	// The friendly name of the task
	Name string

	// The tasks that must successfully complete before this task can start
	Parents []string

	// Concurrency defines constraints on how many instances of this task can run simultaneously
	// and group key expression to evaluate when determining if a task can run
	Concurrency []*types.Concurrency

	// WaitFor represents a set of conditions which must be satisfied before the task can run.
	WaitFor condition.Condition

	// SkipIf represents a set of conditions which, if satisfied, will cause the task to be skipped.
	SkipIf condition.Condition

	// CancelIf represents a set of conditions which, if satisfied, will cause the task to be canceled.
	CancelIf condition.Condition

	// EvictionPolicy controls how this durable task participates in worker-slot eviction.
	// When nil, the task is non-evictable.
	EvictionPolicy *EvictionPolicyOpts

	// The function to execute when the task runs
	// must be a function that takes an input and a DurableHatchetContext and returns an output and an error
	Fn interface{}
}

DurableTaskDeclaration represents a durable task configuration that can be added to a workflow. Durable tasks can use the DurableHatchetContext for operations that persist across worker restarts.

func (*DurableTaskDeclaration[I]) Dump

func (t *DurableTaskDeclaration[I]) Dump(workflowName string, taskDefaults *create.TaskDefaults) *contracts.CreateTaskOpts

func (*DurableTaskDeclaration[I]) GetName

func (t *DurableTaskDeclaration[I]) GetName() string

Implement GetName for DurableTaskDeclaration

type EvictionPolicyOpts added in v0.83.58

type EvictionPolicyOpts struct {
	TTL                   time.Duration
	AllowCapacityEviction bool
	Priority              int
}

EvictionPolicyOpts holds eviction policy parameters for durable tasks.

type NamedTaskImpl

type NamedTaskImpl struct {
	Name string
}

func (*NamedTaskImpl) GetName

func (t *NamedTaskImpl) GetName() string

Implement GetName for NamedTask

type OnFailureTaskDeclaration

type OnFailureTaskDeclaration[I any] struct {
	TaskBase
	TaskShared

	// The function to execute when any tasks in the workflow have failed
	Fn interface{}
}

OnFailureTaskDeclaration represents a task that will be executed if any tasks in the workflow fail.

func (*OnFailureTaskDeclaration[I]) Dump

func (t *OnFailureTaskDeclaration[I]) Dump(workflowName string, taskDefaults *create.TaskDefaults) *contracts.CreateTaskOpts

Dump converts the on failure task declaration into a protobuf request.

type TaskBase

type TaskBase interface {
	Dump(workflowName string, taskDefaults *create.TaskDefaults) *contracts.CreateTaskOpts
}

type TaskDeclaration

type TaskDeclaration[I any] struct {
	TaskBase
	NamedTaskImpl
	TaskShared

	// The friendly name of the task
	Name string

	// The tasks that must successfully complete before this task can start
	Parents []string

	// WaitFor represents a set of conditions which must be satisfied before the task can run.
	WaitFor condition.Condition

	// SkipIf represents a set of conditions which, if satisfied, will cause the task to be skipped.
	SkipIf condition.Condition

	// CancelIf represents a set of conditions which, if satisfied, will cause the task to be canceled.
	CancelIf condition.Condition

	// The function to execute when the task runs
	// must be a function that takes an input and a Hatchet context and returns an output and an error
	Fn interface{}
}

TaskDeclaration represents a standard (non-durable) task configuration that can be added to a workflow.

func (*TaskDeclaration[I]) Dump

func (t *TaskDeclaration[I]) Dump(workflowName string, taskDefaults *create.TaskDefaults) *contracts.CreateTaskOpts

Dump converts the task declaration into a protobuf request.

func (*TaskDeclaration[I]) GetName

func (t *TaskDeclaration[I]) GetName() string

Implement GetName for TaskDeclaration

type TaskShared

type TaskShared struct {
	// ExecutionTimeout specifies the maximum duration a task can run before being terminated
	ExecutionTimeout *time.Duration

	// ScheduleTimeout specifies the maximum time a task can wait to be scheduled
	ScheduleTimeout *time.Duration

	// Retries defines the number of times to retry a failed task
	Retries *int32

	// RetryBackoffFactor is the multiplier for increasing backoff between retries
	RetryBackoffFactor *float32

	// RetryMaxBackoffSeconds is the maximum backoff duration in seconds between retries
	RetryMaxBackoffSeconds *int32

	// RateLimits define constraints on how frequently the task can be executed
	RateLimits []*types.RateLimit

	// WorkerLabels specify requirements for workers that can execute this task
	WorkerLabels map[string]*types.DesiredWorkerLabel

	// Concurrency defines constraints on how many instances of this task can run simultaneously
	Concurrency []*types.Concurrency

	// SlotCost is the number of default worker slots a non-durable task consumes. Defaults to one.
	// Durable tasks ignore it.
	SlotCost *int32

	// Batch configures the task as a batch task. When set, the engine buffers concurrent
	// runs of this task and dispatches them together; retries is always forced to 0.
	Batch *types.BatchConfig

	// The function to execute when the task runs
	// must be a function that takes an input and a Hatchet context and returns an output and an error
	Fn interface{}
}

Jump to

Keyboard shortcuts

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