Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Interface ¶
type Interface interface { Enqueue(obj interface{}) NumRequeues(key string) int Run(stopCh <-chan struct{}, process ProcessFunc) ShutDown() }
type Job ¶
type Job interface { // JobName returns the name of the job. JobName() string // Hash returns a uint64 hash for a job. Hash() uint64 // Run executes the job. Run() // GetDoneCh returns the channel, which when closed, indicates that the job was finished. GetDoneCh() <-chan struct{} }
Job is a runnable interface to queue jobs on a WorkerPool
type ProcessFunc ¶
type WorkerPool ¶
type WorkerPool struct {
// contains filtered or unexported fields
}
WorkerPool object representation
func NewWorkerPool ¶
func NewWorkerPool(nWorkers int) *WorkerPool
NewWorkerPool creates a new work group. If nWorkers is 0, will poll goMaxProcs to get the number of routines to spawn. Reminder: routines are never pinned to system threads, it's up to the go scheduler to decide when and where these will be scheduled.
func (*WorkerPool) AddJob ¶
func (wp *WorkerPool) AddJob(job Job) <-chan struct{}
AddJob posts the job on a worker queue Uses Hash underneath to choose worker to post the job to
func (*WorkerPool) AddJobRoundRobin ¶
func (wp *WorkerPool) AddJobRoundRobin(jobs Job)
AddJobRoundRobin adds a job in round robin to the queues Concurrent calls to AddJobRoundRobin are thread safe and fair between each other
func (*WorkerPool) GetWorkerNumber ¶
func (wp *WorkerPool) GetWorkerNumber() int
GetWorkerNumber get number of queues/workers
Click to show internal directories.
Click to hide internal directories.