package
0.0.0-20190220103131-045890faf5e6
Repository: https://github.com/go-orion/orion.git
Documentation: pkg.go.dev
# README
worker
import "github.com/go-orion/Orion/utils/worker"
Overview
Imported Packages
- github.com/RichardKnop/machinery/v1
- github.com/RichardKnop/machinery/v1/config
- github.com/RichardKnop/machinery/v1/tasks
- github.com/go-orion/Orion/utils/errors
- github.com/go-orion/Orion/utils/log
- github.com/go-orion/Orion/utils/spanutils
- github.com/grpc-ecosystem/go-grpc-middleware/util/metautils
- github.com/opentracing/opentracing-go
- github.com/opentracing/opentracing-go/ext
- github.com/satori/go.uuid
Index
Package files
config.go types.go worker.go workerinfo.go
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 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
Generated by godoc2ghmd
# Functions
NewWorker creates a new worker from given config.
WithQueueName sets the destination queue for this task.
WithRetry sets the number of Retries for this task.
# Structs
Config is the config used to intialize workers.
RabbitMQConfig is the config used for scheduling tasks through rabbitmq.
ScheduleConfig is the config used when scheduling a task.
# Interfaces
Worker is the interface for worker.
# Type aliases
ScheduleOption represents different options available for Schedule.
Work is the type of task that can be exeucted by Worker.