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: 0

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