worker

package
v1.3.11 Latest Latest
Warning

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

Go to latest
Published: Oct 28, 2024 License: GPL-3.0 Imports: 5 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 {
	Ctx          context.Context
	WorkersCount int
	Buffer       int
	MetrixPrefix string
}

Config holds all necessary config for worker

type ErrorHandler

type ErrorHandler func(msg *queue.DecodedSSVMessage, err error) error

ErrorHandler func that handles an error for a specific message

type MsgHandler

type MsgHandler func(msg *queue.DecodedSSVMessage) error

MsgHandler func that receive message.SSVMessage to handle

type Worker

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

Worker listen to queue and process the messages

func NewWorker

func NewWorker(logger *zap.Logger, cfg *Config) *Worker

NewWorker return new Worker

func (*Worker) Close

func (w *Worker) Close()

Close queue and worker listener

func (*Worker) Size

func (w *Worker) Size() int

Size returns the queue size

func (*Worker) TryEnqueue

func (w *Worker) TryEnqueue(msg *queue.DecodedSSVMessage) bool

TryEnqueue tries to enqueue a job to the given job channel. Returns true if the operation was successful, and false if enqueuing would not have been possible without blocking. Job is not enqueued in the latter case.

func (*Worker) UseErrorHandler

func (w *Worker) UseErrorHandler(errHandler ErrorHandler)

UseErrorHandler registers an error handler

func (*Worker) UseHandler

func (w *Worker) UseHandler(handler MsgHandler)

UseHandler registers a message handler

Jump to

Keyboard shortcuts

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