Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrNewJobsNotFound must be returned by a JobScheduleFn when it can't // find new Jobs. ErrNewJobsNotFound = errors.NewKind( "couldn't find new jobs to schedule") // ErrJobSource must be returned by a JobScheduleFn when the source of // job is closed. ErrJobSource = errors.NewKind("job source is closed") )
Functions ¶
This section is empty.
Types ¶
type Job ¶
type Job interface { // Process perform the necessary work on the job. Process(context.Context) error }
Job represents a gitcollector task.
type JobScheduleFn ¶
JobScheduleFn is a function to schedule the next Job.
type MetricsCollector ¶
type MetricsCollector interface { // Start starts collecting metrics. Start() // Stop stops collectingMetrincs. Stop(immediate bool) // Success registers metrics about successfully processed Job. Success(Job) // Faile register metrics about a failed processed Job. Fail(Job) // Discover register metrics about a discovered Job. Discover(Job) }
MetricsCollector represents a component in charge to collect jobs metrics.
type WorkerPool ¶
type WorkerPool struct {
// contains filtered or unexported fields
}
WorkerPool holds a pool of workers to process Jobs.
func NewWorkerPool ¶
func NewWorkerPool( schedule JobScheduleFn, opts *WorkerPoolOpts, ) *WorkerPool
NewWorkerPool builds a new WorkerPool.
func (*WorkerPool) Close ¶
func (wp *WorkerPool) Close()
Close stops all the workers in the pool waiting for the jobs to finish.
func (*WorkerPool) SetWorkers ¶
func (wp *WorkerPool) SetWorkers(n int)
SetWorkers set the number of Workers in the pool to n.
func (*WorkerPool) Size ¶
func (wp *WorkerPool) Size() int
Size returns the current number of workers in the pool.
func (*WorkerPool) Stop ¶
func (wp *WorkerPool) Stop()
Stop stops all the workers in the pool immediately.
type WorkerPoolOpts ¶
type WorkerPoolOpts struct { SchedulerCapacity int ScheduleJobTimeout time.Duration NotWaitNewJobs bool Metrics MetricsCollector }
WorkerPoolOpts are configuration options for a JobScheduler.
Click to show internal directories.
Click to hide internal directories.