worker

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2022 License: GPL-3.0 Imports: 3 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
	Logger       *zap.Logger
	WorkersCount int
	Buffer       int
}

Config holds all necessary config for worker

type Worker

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

Worker listen to queue and process the messages

func NewWorker

func NewWorker(cfg *Config) *Worker

NewWorker return new Worker

func (*Worker) AddHandler

func (w *Worker) AddHandler(handler workerHandler)

AddHandler to work to listen to msg's

func (*Worker) Close

func (w *Worker) Close()

Close queue and worker listener

func (*Worker) TryEnqueue

func (w *Worker) TryEnqueue(msg *message.SSVMessage) 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.

Jump to

Keyboard shortcuts

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