Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Dispatcher ¶
type Dispatcher interface { GetName() string Run(ctx context.Context) error Shutdown() <-chan struct{} // contains filtered or unexported methods }
Dispatcher ...
type LocalDispatcher ¶
type LocalDispatcher struct { Name string WorkerPool chan chan Job MaxWorkers int JobQueue chan Job // contains filtered or unexported fields }
LocalDispatcher - Go channel based job dispatcher for managed job handling where the jobs will be produced and consumed within the instance
func NewLocalDispatcher ¶
func NewLocalDispatcher(name string, maxWorkers int, jobQueue chan Job) (*LocalDispatcher, error)
NewLocalDispatcher - Dispaches the configures number of workers based on the jobs available from the provided Go Channel (JobQueue) Jobs should be produced to the assigned go channel (JobQueue)
func (*LocalDispatcher) GetName ¶
func (d *LocalDispatcher) GetName() string
GetName - Gets the name of the dispatcher
func (*LocalDispatcher) Run ¶
func (d *LocalDispatcher) Run(ctx context.Context) (err error)
Run - Dispatches the workers as per the configuration
func (*LocalDispatcher) Shutdown ¶
func (d *LocalDispatcher) Shutdown() <-chan struct{}
Shutdown - Gracefully shuts down the dispatcher by closing the job enqueuing channel and waits for workers to complete the accepted jobs
type Worker ¶
type Worker struct { WorkerID string WorkerPool chan chan Job JobChannel chan Job // contains filtered or unexported fields }
Worker represents the worker that executes the job