client

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2026 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrWorkflowCanceled = errors.New("workflow canceled")

ErrWorkflowCanceled is returned when a workflow was already canceled.

View Source
var ErrWorkflowTerminated = errors.New("workflow terminated")

ErrWorkflowTerminated is returned when a workflow was already terminated.

Functions

func CreateTypedWorkflowInstance0

func CreateTypedWorkflowInstance0[TResult any](ctx context.Context, c *Client, options WorkflowInstanceOptions, wf workflow.WorkflowFunc0[TResult]) (*workflow.Instance, error)

CreateTypedWorkflowInstance0 creates a workflow instance with no input parameters (type-safe).

func CreateTypedWorkflowInstance1

func CreateTypedWorkflowInstance1[TInput, TResult any](ctx context.Context, c *Client, options WorkflowInstanceOptions, wf workflow.WorkflowFunc1[TInput, TResult], input TInput) (*workflow.Instance, error)

CreateTypedWorkflowInstance1 creates a workflow instance with one input parameter (type-safe).

func CreateTypedWorkflowInstance2

func CreateTypedWorkflowInstance2[TInput1, TInput2, TResult any](ctx context.Context, c *Client, options WorkflowInstanceOptions, wf workflow.WorkflowFunc2[TInput1, TInput2, TResult], input1 TInput1, input2 TInput2) (*workflow.Instance, error)

CreateTypedWorkflowInstance2 creates a workflow instance with two input parameters (type-safe).

func CreateTypedWorkflowInstance3

func CreateTypedWorkflowInstance3[TInput1, TInput2, TInput3, TResult any](ctx context.Context, c *Client, options WorkflowInstanceOptions, wf workflow.WorkflowFunc3[TInput1, TInput2, TInput3, TResult], input1 TInput1, input2 TInput2, input3 TInput3) (*workflow.Instance, error)

CreateTypedWorkflowInstance3 creates a workflow instance with three input parameters (type-safe).

func CreateTypedWorkflowInstanceNoResult0

func CreateTypedWorkflowInstanceNoResult0(ctx context.Context, c *Client, options WorkflowInstanceOptions, wf workflow.WorkflowFuncNoResult0) (*workflow.Instance, error)

CreateTypedWorkflowInstanceNoResult0 creates a workflow instance with no input parameters that returns only error (type-safe).

func CreateTypedWorkflowInstanceNoResult1

func CreateTypedWorkflowInstanceNoResult1[TInput any](ctx context.Context, c *Client, options WorkflowInstanceOptions, wf workflow.WorkflowFuncNoResult1[TInput], input TInput) (*workflow.Instance, error)

CreateTypedWorkflowInstanceNoResult1 creates a workflow instance with one input parameter that returns only error (type-safe).

func CreateTypedWorkflowInstanceNoResult2

func CreateTypedWorkflowInstanceNoResult2[TInput1, TInput2 any](ctx context.Context, c *Client, options WorkflowInstanceOptions, wf workflow.WorkflowFuncNoResult2[TInput1, TInput2], input1 TInput1, input2 TInput2) (*workflow.Instance, error)

CreateTypedWorkflowInstanceNoResult2 creates a workflow instance with two input parameters that returns only error (type-safe).

func CreateTypedWorkflowInstanceNoResult3

func CreateTypedWorkflowInstanceNoResult3[TInput1, TInput2, TInput3 any](ctx context.Context, c *Client, options WorkflowInstanceOptions, wf workflow.WorkflowFuncNoResult3[TInput1, TInput2, TInput3], input1 TInput1, input2 TInput2, input3 TInput3) (*workflow.Instance, error)

CreateTypedWorkflowInstanceNoResult3 creates a workflow instance with three input parameters that returns only error (type-safe).

func GetTypedWorkflowResult0

func GetTypedWorkflowResult0[TResult any](ctx context.Context, c *Client, wf workflow.WorkflowFunc0[TResult], instance *workflow.Instance, timeout time.Duration) (TResult, error)

GetTypedWorkflowResult0 gets the result of a workflow with no input parameters (type-safe).

func GetTypedWorkflowResult1

func GetTypedWorkflowResult1[TInput, TResult any](ctx context.Context, c *Client, wf workflow.WorkflowFunc1[TInput, TResult], instance *workflow.Instance, timeout time.Duration) (TResult, error)

GetTypedWorkflowResult1 gets the result of a workflow with one input parameter (type-safe). It waits for the workflow to finish or until the timeout expires.

func GetTypedWorkflowResult2

func GetTypedWorkflowResult2[TInput1, TInput2, TResult any](ctx context.Context, c *Client, wf workflow.WorkflowFunc2[TInput1, TInput2, TResult], instance *workflow.Instance, timeout time.Duration) (TResult, error)

GetTypedWorkflowResult2 gets the result of a workflow with two input parameters (type-safe).

func GetTypedWorkflowResult3

func GetTypedWorkflowResult3[TInput1, TInput2, TInput3, TResult any](ctx context.Context, c *Client, wf workflow.WorkflowFunc3[TInput1, TInput2, TInput3, TResult], instance *workflow.Instance, timeout time.Duration) (TResult, error)

GetTypedWorkflowResult3 gets the result of a workflow with three input parameters (type-safe).

func GetWorkflowResult

func GetWorkflowResult[T any](ctx context.Context, c *Client, instance *workflow.Instance, timeout time.Duration) (T, error)

GetWorkflowResult gets the workflow result for the given workflow result. It first waits for the workflow to finish or until the given timeout has expired.

Types

type Client

type Client struct {
	// contains filtered or unexported fields
}

func New

func New(backend backend.Backend) *Client

New creates a new client for the given backend.

func (*Client) CancelWorkflowInstance

func (c *Client) CancelWorkflowInstance(ctx context.Context, instance *workflow.Instance) error

CancelWorkflowInstance cancels a running workflow instance.

func (*Client) CreateWorkflowInstance

func (c *Client) CreateWorkflowInstance(ctx context.Context, options WorkflowInstanceOptions, wf workflow.Workflow, args ...any) (*workflow.Instance, error)

CreateWorkflowInstance creates a new workflow instance of the given workflow.

func (*Client) GetStats

func (c *Client) GetStats(ctx context.Context) (*backend.Stats, error)

GetStats returns backend stats.

func (*Client) GetWorkflowInstanceState

func (c *Client) GetWorkflowInstanceState(ctx context.Context, instance *workflow.Instance) (core.WorkflowInstanceState, error)

GetWorkflowInstanceState returns the current state of the given workflow instance

func (*Client) RemoveWorkflowInstance

func (c *Client) RemoveWorkflowInstance(ctx context.Context, instance *core.WorkflowInstance) error

RemoveWorkflowInstance removes the given workflow instance from the backend.

Instance needs to be in a completed state.

func (*Client) RemoveWorkflowInstances

func (c *Client) RemoveWorkflowInstances(ctx context.Context, options ...backend.RemovalOption) error

RemoveWorkflowInstances removes completed workflow instances from the backend.

func (*Client) SignalWorkflow

func (c *Client) SignalWorkflow(ctx context.Context, instanceID string, name string, arg any) error

SignalWorkflow signals a running workflow instance.

func (*Client) StartAutoExpiration

func (c *Client) StartAutoExpiration(ctx context.Context, delay time.Duration) error

StartAutoExpiration starts a system workflow that will automatically expire workflow instances.

The workflow will run every `delay` and remove all workflow instances finished before Now() - `delay`.

func (*Client) WaitForWorkflowInstance

func (c *Client) WaitForWorkflowInstance(ctx context.Context, instance *workflow.Instance, timeout time.Duration) error

WaitForWorkflowInstance waits for the given workflow instance to finish or until the given timeout has expired.

type WorkflowInstanceOptions

type WorkflowInstanceOptions struct {
	// Queue is the queue the workflow instance will be created in. Must be a valid queue
	// for the given backend. If not set, will default to the default queue
	Queue workflow.Queue

	InstanceID string
}

Jump to

Keyboard shortcuts

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