task

package
v0.56.4 Latest Latest
Warning

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

Go to latest
Published: Mar 27, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CreateOpts added in v0.55.26

type CreateOpts[I any] struct {
	// (required) The name of the task
	Name string

	// (optional) ExecutionTimeout specifies the maximum duration a task can run before being terminated
	ExecutionTimeout time.Duration

	// (optional) ScheduleTimeout specifies the maximum time a task can wait to be scheduled
	ScheduleTimeout time.Duration

	// (optional) Retries defines the number of times to retry a failed task
	Retries int32

	// (optional) RetryBackoffFactor is the multiplier for increasing backoff between retries
	RetryBackoffFactor float32

	// (optional) RetryMaxBackoffSeconds is the maximum backoff duration in seconds between retries
	RetryMaxBackoffSeconds int32

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

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

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

	// (optional) Conditions specifies when this task should be executed
	Conditions *types.TaskConditions

	// (optional) Parents defines the tasks that must complete before this task can start
	// Accept either NamedTask pointers (for backward compatibility) or NamedTaskInterface
	Parents []NamedTask

	// (optional) Fn is the function to execute when the task runs
	// must be a function that takes an input and a worker.HatchetContext and returns an output and an error
	Fn interface{}
}

CreateOpts is the options for creating a task.

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

	// Conditions specifies when this task should be executed
	Conditions *types.TaskConditions

	// 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 *TaskDefaults) *contracts.CreateTaskOpts

func (*DurableTaskDeclaration[I]) GetName

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

Implement GetName for DurableTaskDeclaration

type NamedTask added in v0.55.26

type NamedTask interface {
	// GetName returns the name of the task
	GetName() string
}

NamedTask defines an interface for task types that have a name

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 *TaskDefaults) *contracts.CreateTaskOpts

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

type TaskBase

type TaskBase interface {
	Dump(workflowName string, taskDefaults *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

	// Conditions specifies when this task should be executed
	Conditions *types.TaskConditions

	// 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 *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 TaskDefaults added in v0.55.26

type TaskDefaults struct {
	// (optional) ExecutionTimeout specifies the maximum duration a task can run after starting before being terminated
	ExecutionTimeout time.Duration

	// (optional) ScheduleTimeout specifies the maximum time a task can wait in the queue to be scheduled
	ScheduleTimeout time.Duration

	// (optional) Retries defines the number of times to retry a failed task
	Retries int32

	// (optional) RetryBackoffFactor is the multiplier for increasing backoff between retries
	RetryBackoffFactor float32

	// (optional) RetryMaxBackoffSeconds is the maximum backoff duration in seconds between retries
	RetryMaxBackoffSeconds int32
}

TaskDefaults defines default configuration values for tasks within a workflow.

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

	// 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