worker

package
v0.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 23, 2024 License: MIT Imports: 4 Imported by: 1 module, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Job

type Job struct {
	Type    string
	Payload interface{}
}

Job represents a unit of work to be processed by a worker.

type Scheduler

type Scheduler struct {
	// contains filtered or unexported fields
}

Scheduler handles periodic scheduling of jobs.

func NewScheduler

func NewScheduler(wp *WorkerPool) *Scheduler

NewScheduler initializes a new Scheduler.

func (*Scheduler) Start

func (s *Scheduler) Start()

Start begins the scheduler.

func (*Scheduler) Stop

func (s *Scheduler) Stop()

Stop stops the scheduler.

type WorkerPool

type WorkerPool struct {
	JobQueue   chan Job
	NumWorkers int
	// contains filtered or unexported fields
}

WorkerPool manages a pool of workers to process jobs.

func NewWorkerPool

func NewWorkerPool(db *db.Database, numWorkers int) *WorkerPool

NewWorkerPool initializes a new WorkerPool.

func (*WorkerPool) Start

func (wp *WorkerPool) Start()

Start initializes the worker pool and starts processing jobs.

func (*WorkerPool) Stop

func (wp *WorkerPool) Stop()

Stop gracefully shuts down the worker pool.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL