Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct { IsQueueEmpty bool Result chan Result // contains filtered or unexported fields }
Client is a Que client that can add jobs to the queue and remove jobs from the queue.
func NewQue ¶
func NewQue() *Client
NewClient create our new local queue Note: we are creating 5000 queue as we expect this to not reach this high. If due to delay and this limit is reached, it may cause deadlock if all channels want to write This was implemented crudely as PoC so fixes should be considered if used in production. Eg: maybe a slice/array to store the jobs being added to the client and have a channel dedicated to pushing the job out to workers.
type Job ¶
type Job struct { Type string // Args can be anything depends on the job Args interface{} }
Job is a single unit of work for Que to perform.
type Manager ¶
Manager is a single "worker" that check for when the job channel is empty This is done by checking the workerstatus channel and look for instances where all workers are waiting for job. This also only works because channel in GO are FIFO so we can get latest workers statuses
type Result ¶
type Result struct { JobType string // Args can be anything depends on the job Result interface{} }
Result is the output of a Job and can be used to send something back to mainthread.
type WorkFunc ¶
generic WorkFunc is a function that performs a Job. If an error is returned, the job is reenqueued with exponential backoff.
type WorkMap ¶
WorkMap is a map of Job names to WorkFuncs that are used to perform Jobs of a given type.
type Worker ¶
Worker is a single worker that pulls jobs off the specified Queue. If no Job is found, the Worker will sleep for Interval seconds.
type WorkerPool ¶
type WorkerPool struct { WorkMap WorkMap Interval time.Duration // contains filtered or unexported fields }
WorkerPool is a pool of Workers, each working jobs from the queue Queue at the specified Interval using the WorkMap.
func NewWorkerPool ¶
func NewWorkerPool(c *Client, wm WorkMap, count int) *WorkerPool
NewWorkerPool creates a new WorkerPool with count workers using the Client c.
func (*WorkerPool) Start ¶
func (w *WorkerPool) Start(ctx context.Context)
Start starts all of the Workers in the WorkerPool.