Documentation ¶
Index ¶
- type Worker
- type WorkerAdmin
- func (a *WorkerAdmin) AddWorker(w Worker)
- func (a *WorkerAdmin) IsWorkerRunning(name string) bool
- func (a *WorkerAdmin) QueueMessage(m interface{}) bool
- func (a *WorkerAdmin) QueueSize() int
- func (a *WorkerAdmin) StopAll(blocking bool) error
- func (a *WorkerAdmin) StopWorker(name string, blocking bool) error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Worker ¶
type Worker interface { // Name should return a unique identifier for a particular worker Name() string // DoWork should receive a message, and perform the actual work, only an error should be returned DoWork(message interface{}) error // OnError will be called if DoWork returns an error != nil OnError(e error) // Cleanup will be called when the worker is shutting down Cleanup() error // FailureTime should return the amount of time the worker should wait after resuming work if an error occurs FailureTime() int64 }
Worker interface should be implemented by concrete workers that will perform the actual job
type WorkerAdmin ¶
type WorkerAdmin struct {
// contains filtered or unexported fields
}
WorkerAdmin struct handles multiple worker execution, popping jobs from a single queue
func NewWorkerAdmin ¶
func NewWorkerAdmin(queueSize int, logger logging.LoggerInterface) *WorkerAdmin
NewWorkerAdmin instantiates a new WorkerAdmin and returns a pointer to it.
func (*WorkerAdmin) AddWorker ¶
func (a *WorkerAdmin) AddWorker(w Worker)
AddWorker registers a new worker in the admin
func (*WorkerAdmin) IsWorkerRunning ¶
func (a *WorkerAdmin) IsWorkerRunning(name string) bool
IsWorkerRunning returns true if the worker exists and is currently running
func (*WorkerAdmin) QueueMessage ¶
func (a *WorkerAdmin) QueueMessage(m interface{}) bool
QueueMessage adds a new message that will be popped by a worker and processed
func (*WorkerAdmin) QueueSize ¶
func (a *WorkerAdmin) QueueSize() int
QueueSize returns the current queue size
func (*WorkerAdmin) StopAll ¶
func (a *WorkerAdmin) StopAll(blocking bool) error
StopAll ends all worker's event loops
func (*WorkerAdmin) StopWorker ¶
func (a *WorkerAdmin) StopWorker(name string, blocking bool) error
StopWorker ends the worker's event loop, preventing it from picking further jobs
Click to show internal directories.
Click to hide internal directories.