queue

package
v0.0.0-...-fcc4a6d Latest Latest
Warning

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

Go to latest
Published: Jun 23, 2022 License: ISC 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
	Payload []byte
	Action  func(payload []byte) error
}

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

func (Job) GetName

func (j Job) GetName() string

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, limit int) *Queue

NewQueue instantiates new queue.

func (*Queue) AddJob

func (q *Queue) AddJob(job Job)

AddJob sends job to the channel.

type Worker

type Worker struct {
	Queue *Queue
}

Worker responsible for queue serving.

func NewWorker

func NewWorker(queue *Queue) *Worker

NewWorker initializes a 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