worker

package
v1.28.0 Latest Latest
Warning

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

Go to latest
Published: Apr 29, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoActivities                   = errors.New("no activities provided")
	ErrNoWorkflows                    = errors.New("no workflows provided")
	ErrWorkerRegistrationConfigNotSet = errors.New("workflows and activities not set")
)

Functions

This section is empty.

Types

type Worker

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

func New

func New(config *WorkerConfig) *Worker

func (*Worker) Start

func (c *Worker) Start() error

Start initiates the execution of the Temporal worker, allowing it to start processing workflows and activities. It will block until an interrupt signal is received. In case of failure to start the worker, the application will terminate with a log.Fatal.

type WorkerConfig

type WorkerConfig struct {
	TaskQueue               string
	MaxConcurrentActivities int
	MaxConcurrentWorkflows  int
	WorkerOptions           worker.Options
	Client                  client.Client
	Logger                  *zap.Logger
	Activities              []any
	Workflows               []any
}

WorkerConfig holds the configuration for the Temporal worker.

func NewWorkerConfig

func NewWorkerConfig(opts ...WorkerOption) *WorkerConfig

NewWorkerConfig initializes a WorkerConfig with the given options.

type WorkerOption

type WorkerOption func(*WorkerConfig)

WorkerOption defines a type for functional options.

func WithActivities

func WithActivities(activities ...any) WorkerOption

func WithClient

func WithClient(client client.Client) WorkerOption

WithClient sets the Temporal client for the worker.

func WithLogger

func WithLogger(logger *zap.Logger) WorkerOption

WithLogger sets the logger for the worker.

func WithMaxConcurrentActivities

func WithMaxConcurrentActivities(max int) WorkerOption

WithMaxConcurrentActivities sets the maximum number of concurrent activities.

func WithMaxConcurrentWorkflows

func WithMaxConcurrentWorkflows(max int) WorkerOption

WithMaxConcurrentWorkflows sets the maximum number of concurrent workflows.

func WithTaskQueue

func WithTaskQueue(taskQueue string) WorkerOption

WithTaskQueue sets the task queue for the worker.

func WithWorkerOptions

func WithWorkerOptions(options worker.Options) WorkerOption

WithWorkerOptions sets additional options for the worker.

func WithWorkflows

func WithWorkflows(workflows ...any) WorkerOption

WithMaxConcurrentActivities sets the maximum number of concurrent activities.

Jump to

Keyboard shortcuts

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