worker

package
v0.3.0-alpha.5 Latest Latest
Warning

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

Go to latest
Published: Jan 3, 2024 License: MIT Imports: 14 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Fn

func Fn(f any) workflowFn

Types

type Action

type Action interface {
	// Name returns the name of the action
	Name() string

	// Run runs the action
	Run(args ...any) []any

	MethodFn() any
}

Action is an individual action that can be run by the worker.

type Cron

type Cron string

func (Cron) ToWorkflowTriggers

func (c Cron) ToWorkflowTriggers(wt *types.WorkflowTriggers)

type Crons

type Crons []string

func (Crons) ToWorkflowTriggers

func (c Crons) ToWorkflowTriggers(wt *types.WorkflowTriggers)

type Event

type Event string

func (Event) ToWorkflowTriggers

func (e Event) ToWorkflowTriggers(wt *types.WorkflowTriggers)

type Events

type Events []string

func (Events) ToWorkflowTriggers

func (e Events) ToWorkflowTriggers(wt *types.WorkflowTriggers)

type Service

type Service struct {
	Name string
	// contains filtered or unexported fields
}

func (*Service) On

func (s *Service) On(t triggerConverter, workflow workflowConverter) error

func (*Service) RegisterAction

func (s *Service) RegisterAction(fn any) error

type Worker

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

func NewWorker

func NewWorker(fs ...WorkerOpt) (*Worker, error)

NewWorker creates a new worker instance

func (*Worker) NewService

func (w *Worker) NewService(name string) *Service

func (*Worker) On

func (w *Worker) On(t triggerConverter, workflow workflowConverter) error

func (*Worker) RegisterAction

func (w *Worker) RegisterAction(name string, method any) error

func (*Worker) Start

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

Start starts the worker in blocking fashion

type WorkerOpt

type WorkerOpt func(*WorkerOpts)

func WithClient

func WithClient(client client.Client) WorkerOpt

func WithErrorAlerter

func WithErrorAlerter(alerter errors.Alerter) WorkerOpt

func WithIntegration

func WithIntegration(integration integrations.Integration) WorkerOpt

func WithName

func WithName(name string) WorkerOpt

type WorkerOpts

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

type Workflow

type Workflow struct {
	Jobs []WorkflowJob
}

type WorkflowJob

type WorkflowJob struct {
	// The name of the job
	Name string

	Description string

	Timeout string

	// The steps that are run in the job
	Steps []WorkflowStep
}

func (*WorkflowJob) ToActionMap

func (j *WorkflowJob) ToActionMap(svcName string) map[string]any

func (*WorkflowJob) ToWorkflow

func (j *WorkflowJob) ToWorkflow(svcName string) types.Workflow

func (*WorkflowJob) ToWorkflowJob

func (j *WorkflowJob) ToWorkflowJob(svcName string) (*types.WorkflowJob, error)

type WorkflowStep

type WorkflowStep struct {
	// The step timeout
	Timeout string

	// The executed function
	Function any

	// The step id. If not set, one will be generated from the function name
	ID string
}

func (*WorkflowStep) GetActionId

func (s *WorkflowStep) GetActionId(svcName string, index int) string

func (*WorkflowStep) GetStepId

func (s *WorkflowStep) GetStepId(index int) string

func (*WorkflowStep) ToWorkflowStep

func (s *WorkflowStep) ToWorkflowStep(prevStep *step, svcName string, index int) (*step, error)

Jump to

Keyboard shortcuts

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