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

workflows

package
v0.0.0-...-40c6b5d Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2026 License: MIT Imports: 27 Imported by: 0

README

Workflows

This package adapts go-workflows runtime, client, worker, and diagnostic APIs for AuthProxy. The persisted workflow history and argument encoding are private go-workflows protocols, not AuthProxy API resources.

Durable workflow registrations include a version suffix such as .v1, and their Go input types carry the same version. Current workflow inputs contain scalar AuthProxy IDs and operation parameters; none embeds a v1alpha1 resource object. The task/queue/workflow API migration therefore leaves persisted arguments, retry behavior, resume behavior, and idempotent instance IDs intact. Any future workflow input that embeds a resource must use a new registration name and input type rather than changing a persisted definition in place.

Documentation

Index

Constants

View Source
const (
	DefaultQueue = wflib.QueueDefault
)

Variables

This section is empty.

Functions

func MigrationStatus

func MigrationStatus(
	ctx context.Context,
	root *sconfig.Root,
) migration.Status

MigrationStatus returns the status of the workflow database migrations.

func RunMigrations

func RunMigrations(
	ctx context.Context,
	root *sconfig.Root,
	logger *slog.Logger,
	direction migration.Direction,
	version *uint,
	opts ...MigrateOption,
) error

RunMigrations runs the workflow database migrations.

Types

type Client

type Client interface {
	CreateWorkflowInstance(
		ctx context.Context,
		options client.WorkflowInstanceOptions,
		workflow wflib.Workflow,
		args ...any,
	) (*wflib.Instance, error)
	GetWorkflowInstanceState(
		ctx context.Context,
		instance *wflib.Instance,
	) (wfcore.WorkflowInstanceState, error)
	GetWorkflowInstanceHistory(
		ctx context.Context,
		instance *wflib.Instance,
		lastSequenceID *int64,
	) ([]*history.Event, error)
}

type MigrateOption

type MigrateOption func(*migrateOptions)

func WithPostgresMigrationDB

func WithPostgresMigrationDB(db *sql.DB) MigrateOption

type Runtime

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

func NewRuntime

func NewRuntime(
	root *sconfig.Root,
	telemetry *aptelemetry.Providers,
	logger *slog.Logger,
	opts ...RuntimeOption,
) (*Runtime, error)

func (*Runtime) Backend

func (r *Runtime) Backend() wfbackend.Backend

func (*Runtime) Client

func (r *Runtime) Client() Client

func (*Runtime) Close

func (r *Runtime) Close() error

func (*Runtime) CreateWorkflowInstance

func (r *Runtime) CreateWorkflowInstance(ctx context.Context, options client.WorkflowInstanceOptions, workflow wflib.Workflow, args ...any) (*wflib.Instance, error)

func (*Runtime) DiagnosticBackend

func (r *Runtime) DiagnosticBackend() (diag.Backend, error)

func (*Runtime) GetWorkflowInstanceHistory

func (r *Runtime) GetWorkflowInstanceHistory(ctx context.Context, instance *wflib.Instance, lastSequenceID *int64) ([]*history.Event, error)

func (*Runtime) GetWorkflowInstanceState

func (r *Runtime) GetWorkflowInstanceState(ctx context.Context, instance *wflib.Instance) (wfcore.WorkflowInstanceState, error)

func (*Runtime) Ping

func (r *Runtime) Ping(ctx context.Context) bool

func (*Runtime) RemoveWorkflowInstances

func (r *Runtime) RemoveWorkflowInstances(ctx context.Context, options ...wfbackend.RemovalOption) error

RemoveWorkflowInstances permanently deletes finished workflow instances and their history that match options.

type RuntimeOption

type RuntimeOption func(*runtimeOptions)

func WithPostgresDB

func WithPostgresDB(db *sql.DB) RuntimeOption

type TaskHandler

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

TaskHandler owns the Asynq maintenance tasks for the workflow runtime. It is registered with the worker's mux and scheduler like the other task handlers.

func NewTaskHandler

func NewTaskHandler(runtime *Runtime, cfg *sconfig.Tasks, logger *slog.Logger) *TaskHandler

NewTaskHandler creates the handler for workflow maintenance tasks. cfg may be nil, in which case the default retention applies.

func (*TaskHandler) GetCronTasks

func (h *TaskHandler) GetCronTasks() []*asynq.PeriodicTaskConfig

GetCronTasks returns the daily cleanup of finished workflow instances, or nothing when retention is disabled.

func (*TaskHandler) RegisterTasks

func (h *TaskHandler) RegisterTasks(mux *asynq.ServeMux)

RegisterTasks registers the workflow maintenance task handlers with the Asynq mux.

type Worker

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

func NewWorker

func NewWorker(runtime *Runtime, options *wfworker.Options) (*Worker, error)

func (*Worker) RegisterActivity

func (w *Worker) RegisterActivity(activity wflib.Activity, opts ...registry.RegisterOption) error

func (*Worker) RegisterWorkflow

func (w *Worker) RegisterWorkflow(workflow wflib.Workflow, opts ...registry.RegisterOption) error

func (*Worker) Start

func (w *Worker) Start(ctx context.Context) error

func (*Worker) WaitForCompletion

func (w *Worker) WaitForCompletion() error

Jump to

Keyboard shortcuts

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