queue

package
v0.8.59 Latest Latest
Warning

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

Go to latest
Published: Sep 1, 2023 License: GPL-3.0 Imports: 3 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 {
	Name   string
	Action func() error
}

Job - holds logic to perform some operations during queue execution.

func (Job) Run

func (j Job) Run() error

Run performs job execution.

type Queue

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

Queue holds name, list of jobs and context with cancel.

func NewQueue

func NewQueue(name string) *Queue

NewQueue instantiates new queue.

func (*Queue) AddJob

func (q *Queue) AddJob(job Job)

AddJob sends job to the channel.

func (*Queue) AddJobs

func (q *Queue) AddJobs(jobs []Job)

AddJobs adds jobs to the queue and cancels channel.

type Worker

type Worker struct {
	Queue *Queue
}

Worker responsible for queue serving.

func NewWorker

func NewWorker(queue *Queue) *Worker

NewWorker initialises new Worker.

func (*Worker) DoWork

func (w *Worker) DoWork() bool

DoWork processes jobs from the queue (jobs channel).

Jump to

Keyboard shortcuts

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