delivery

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultMaxResponseBytes = 16 << 10

DefaultMaxResponseBytes is enough for a rejection to explain itself and far short of anything worth storing per attempt.

View Source
const HTTP = outbound.HTTP

HTTP names the transport this project ships. Re-exported so a caller wiring the registry does not need two packages.

Variables

View Source
var ErrUnknownTransport = errors.New("no transport is registered for that kind of destination")

Functions

func CanRead

func CanRead(reference string) error

CanRead reports whether a reference resolves here, which is what the process that delivers knows and the panel cannot: they run apart, with different environments and different filesystems.

Types

type Build

type Build func(Options) (outbound.Transport, error)

Build makes a transport from the settings a deployment gave it.

type Config

type Config struct {
	Transports     *Transports
	Workers        int
	BatchSize      int
	SafetyInterval time.Duration
	RequestTimeout time.Duration
	// MaxResponseBytes is how much of what a destination says back is kept on
	// the attempt. Zero takes the default.
	MaxResponseBytes int64
	MaxAttempts      int
	BackoffBase      time.Duration
	BackoffCap       time.Duration
	Logger           *slog.Logger
}

type Dispatcher

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

func New

func New(queue Queue, cfg Config) *Dispatcher

func (*Dispatcher) Run

func (d *Dispatcher) Run(ctx context.Context) error

func (*Dispatcher) Tick

func (d *Dispatcher) Tick(ctx context.Context) (int, error)

type Options

type Options struct {
	RequestTimeout time.Duration
	Client         *http.Client
	// MaxResponseBytes is how much of what a destination says back is kept.
	// It is a diagnostic, not an archive, so it is bounded and says when it
	// was cut.
	MaxResponseBytes int64
}

Options are what any transport may need. A transport reads the fields it understands and ignores the rest, so registering one does not change this type for the others.

type Queue

type Queue interface {
	Plan(ctx context.Context, batch int) (int, error)
	Claim(ctx context.Context, batch int, lease time.Duration) ([]outbound.Delivery, error)
	MarkDelivered(ctx context.Context, tenant, id uuid.UUID, status int) error
	MarkFailed(ctx context.Context, tenant, id uuid.UUID, nextAttempt time.Time,
		status int, reason string, maxAttempts int) error
	RecordAttempt(ctx context.Context, tenant, deliveryID uuid.UUID, attempt, status int,
		signedWith []string, answer outbound.Answer,
		reason string, took time.Duration) error
	NextWorkAt(ctx context.Context) (time.Time, bool, error)
	Notifications(ctx context.Context) <-chan struct{}
}

type Transports

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

Transports maps a kind of destination to the code that talks to it. Supporting a broker is a call to Register, not an edit to the delivery loop.

func DefaultTransports

func DefaultTransports() *Transports

DefaultTransports is what this project ships with.

func NewTransports

func NewTransports() *Transports

func (*Transports) Build

func (t *Transports) Build(kind string, options Options) outbound.Transport

Build the transport for a kind. An unknown kind yields one that refuses: an attempt is recorded against it and not retried, because retrying cannot register a transport.

func (*Transports) Kinds

func (t *Transports) Kinds() []string

func (*Transports) Knows

func (t *Transports) Knows(kind string) bool

func (*Transports) Register

func (t *Transports) Register(kind string, build Build)

Jump to

Keyboard shortcuts

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