client

package
v0.19.0 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2024 License: MIT Imports: 21 Imported by: 24

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 GetWorkflowResult added in v0.0.4

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 added in v0.16.1

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

GetStats returns backend stats.

func (*Client) GetWorkflowInstanceState added in v0.19.0

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 added in v0.12.0

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 added in v0.19.0

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 added in v0.19.0

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 added in v0.0.4

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