Documentation ¶
Overview ¶
Package workers provides primitives for configuration and starting worker queues
Index ¶
- Variables
- type Configuration
- type EventHandler
- type Handler
- type Worker
- func (w *Worker) Close() error
- func (w *Worker) Config() *Configuration
- func (w *Worker) Init() error
- func (w *Worker) OnEndWorker()
- func (w *Worker) OnPostTask(task *common.Task, threadId int)
- func (w *Worker) OnPreTask(task *common.Task, threadId int)
- func (w *Worker) OnStartWorker()
- func (w *Worker) OnTaskError(task *common.Task, err error)
- func (w *Worker) OnTaskHeartbeat(task *common.Task)
- func (w *Worker) OnTaskResult(task *common.Task, a ...interface{})
- func (w *Worker) OnTaskSuccess(task *common.Task)
- func (w *Worker) OnThreadHeartbeat(threadId int)
- func (w *Worker) SetEventHandler(eventHandler EventHandler)
- func (w *Worker) SetTaskEventHandler(eventHandler common.TaskProcessEventHandler)
- func (w *Worker) StartWorker()
- func (w *Worker) StopWorker()
- func (w *Worker) TaskQueue() chan<- *common.Task
Constants ¶
This section is empty.
Variables ¶
Functions ¶
This section is empty.
Types ¶
type Configuration ¶
type Configuration struct { //Number of pre-initialized task thread Concurrency int //Waiting time for worker to wait task threads closing WaitTaskThreadsToClose time.Duration //Waiting time to issue heartbeat Heartbeat time.Duration }
Configuration stores initialization data for worker server
func NewConfiguration ¶
func NewConfiguration() *Configuration
type EventHandler ¶
type Handler ¶
type Handler interface { Init() error Close() error Config() *Configuration TaskQueue() chan<- *common.Task SetEventHandler(eventHandler EventHandler) SetTaskEventHandler(eventHandler common.TaskProcessEventHandler) StartWorker() StopWorker() }
type Worker ¶
type Worker struct { *Configuration // contains filtered or unexported fields }
TODO: Benchmark tests Worker stores configuration for server activation
func NewWorker ¶
func NewWorker(config *Configuration, connectorHandler connector.Handler) *Worker
NewWorker creates and configures Worker instance
func (*Worker) Config ¶
func (w *Worker) Config() *Configuration
func (*Worker) OnEndWorker ¶
func (w *Worker) OnEndWorker()
func (*Worker) OnStartWorker ¶
func (w *Worker) OnStartWorker()
func (*Worker) OnTaskHeartbeat ¶
func (*Worker) OnTaskResult ¶
func (*Worker) OnTaskSuccess ¶
func (*Worker) OnThreadHeartbeat ¶
func (*Worker) SetEventHandler ¶
func (w *Worker) SetEventHandler(eventHandler EventHandler)
SetEventHandler
func (*Worker) SetTaskEventHandler ¶
func (w *Worker) SetTaskEventHandler(eventHandler common.TaskProcessEventHandler)
SetTaskEventHandler
Click to show internal directories.
Click to hide internal directories.