queue

package
v1.9.1 Latest Latest
Warning

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

Go to latest
Published: Mar 20, 2021 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package queue contains a simple job queue implementation for running concurrent jobs.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Job

type Job struct {
	ID string
}

The Job type represents a single unit of work.

type Option

type Option func(c *config)

The Option type is a function that modifies the queue configuration.

func MaxWorkers

func MaxWorkers(max int) Option

MaxWorkers specifies the maximum amount of concurrent jobs that the queue can process.

type Queue

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

The Queue type is responsible for queueing and executing concurrent jobs.

func New

func New(ctx context.Context, wf WorkFunc, opts ...Option) *Queue

New creates a new *Queue instance with the specified configuration options.

func (*Queue) Add

func (q *Queue) Add(ctx context.Context, job Job) error

Add a job to the queue.

func (*Queue) Errors

func (q *Queue) Errors() <-chan error

Errors exposes the errors channel for reading.

type WorkFunc

type WorkFunc func(ctx context.Context, j Job) error

WorkFunc is a function invoked for each job.

Jump to

Keyboard shortcuts

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