worker

package
v2.0.0-...-1c13370 Latest Latest
Warning

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

Go to latest
Published: Feb 22, 2023 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config struct {
	LocalMode    bool
	RabbitConfig *RabbitMQConfig
}

Config is the config used to intialize workers

type RabbitMQConfig

type RabbitMQConfig struct {
	UserName    string
	Password    string
	BrokerVHost string
	Host        string
	Port        string
	QueueName   string
}

RabbitMQConfig is the config used for scheduling tasks through rabbitmq

type ScheduleConfig

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

ScheduleConfig is the config used when scheduling a task

type ScheduleOption

type ScheduleOption func(*ScheduleConfig)

ScheduleOption represents different options available for Schedule

func WithETA

func WithETA(eta *time.Time) ScheduleOption

WithETA sets the delay for this task

func WithQueueName

func WithQueueName(queueName string) ScheduleOption

WithQueueName sets the destination queue for this task

func WithRetry

func WithRetry(n int) ScheduleOption

WithRetry sets the number of Retries for this task

type Work

type Work func(ctx context.Context, payload string) error

Work is the type of task that can be exeucted by Worker

type Worker

type Worker interface {
	Schedule(ctx context.Context, name, payload string, options ...ScheduleOption) error
	RegisterTask(name string, taskFunc Work) error
	RunWorker(name string, concurrency int)
	CloseWorker()
}

Worker is the interface for worker

func NewWorker

func NewWorker(config Config) Worker

NewWorker creates a new worker from given config

Jump to

Keyboard shortcuts

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