producer

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: May 9, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Config

type Config[P any, S any, T Enqueuer[P, S]] struct {
	// Enqueuer represents the enqueuer of Jobs. This can be the *relay.Client or other wrapper.
	Enqueuer T

	// Backoff if the backoff used when calling `enqueue`.
	// Optional: If not set a default backoff is used.
	Backoff backoff.Exponential
}

Config contains all information needed to initialize a Producer.

type Enqueuer

type Enqueuer[P any, S any] interface {
	Enqueue(context.Context, relay.Job[P, S]) error
	EnqueueBatch(context.Context, []relay.Job[P, S]) error
}

Enqueuer represents the enqueuer of Jobs.

type Producer

type Producer[P any, S any, T Enqueuer[P, S]] struct {
	// contains filtered or unexported fields
}

Producer is a wrapper around the low-level Relay Client to abstract away retrying and other bits.

func New

func New[P any, S any, T Enqueuer[P, S]](cfg Config[P, S, T]) (*Producer[P, S, T], error)

New create a Producer for use.

func (*Producer[P, S, T]) Enqueue

func (p *Producer[P, S, T]) Enqueue(ctx context.Context, job relay.Job[P, S]) (err error)

Enqueue submits the provided Job for processing to the Job Server using the provided Enqueuer.

func (*Producer[P, S, T]) EnqueueBatch

func (p *Producer[P, S, T]) EnqueueBatch(ctx context.Context, jobs []relay.Job[P, S]) (err error)

EnqueueBatch submits multiple Jobs for processing to the Job Server in one call using the provided Enqueuer.

Jump to

Keyboard shortcuts

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