queuepoller

package
v0.7.3 Latest Latest
Warning

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

Go to latest
Published: Feb 10, 2026 License: Apache-2.0, MIT Imports: 7 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handler

type Handler[Job any] interface {
	// contains filtered or unexported methods
}

Handler processes jobs of the given type.

func BatchJobHandler

func BatchJobHandler[Job any](handler func(ctx context.Context, jobs []WithID[Job]) map[string]error) Handler[Job]

BatchJobHandler creates a Handler from a function that processes multiple jobs.

func JobHandler

func JobHandler[Job any](handler func(ctx context.Context, j Job) error) Handler[Job]

JobHandler creates a Handler from a function that processes single jobs.

type Option

type Option func(*config)

Option configures the CachingQueuePoller

func WithConcurrency

func WithConcurrency(concurrency int) Option

WithConcurrency sets the maximum number of concurrent job processing

func WithJobBatchSize

func WithJobBatchSize(size int) Option

WithJobBatchSize sets the maximum number of jobs to process in a batch

type Queue

type Queue[Job any] interface {
	QueueQueuer[Job]
	QueueReader[Job]
	QueueReleaser
	QueueDeleter
}

Queue is an interface for a job queue, combining queuing, reading, releasing, and deleting jobs.

type QueueDeleter

type QueueDeleter interface {
	Delete(ctx context.Context, jobID string) error
}

QueueDeleter is an interface for deleting jobs from the queue.

type QueuePoller

type QueuePoller[Job any] struct {
	// contains filtered or unexported fields
}

QueuePoller polls a queue for jobs and processes them using the provided JobHandler.

func NewQueuePoller

func NewQueuePoller[Job any](queue Queue[Job], handler Handler[Job], opts ...Option) (*QueuePoller[Job], error)

NewQueuePoller creates a new QueuePoller instance.

func (*QueuePoller[Job]) Start

func (p *QueuePoller[Job]) Start()

Start begins polling the queue for caching jobs.

func (*QueuePoller[Job]) Stop

func (p *QueuePoller[Job]) Stop()

Stop stops the polling loop and waits for it to finish.

type QueueQueuer

type QueueQueuer[Job any] interface {
	Queue(ctx context.Context, job Job) error
}

QueueQueuer is an interface for queuing jobs.

type QueueReader

type QueueReader[Job any] interface {
	Read(ctx context.Context, maxJobs int) ([]WithID[Job], error)
}

QueueReader is an interface for reading jobs from the queue.

type QueueReleaser

type QueueReleaser interface {
	Release(ctx context.Context, jobID string) error
}

QueueReleaser is an interface for releasing jobs from the queue.

type WithID

type WithID[Job any] struct {
	ID  string
	Job Job
}

Jump to

Keyboard shortcuts

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