Documentation
¶
Index ¶
Constants ¶
const DefaultMaxResponseBytes = 16 << 10
DefaultMaxResponseBytes is enough for a rejection to explain itself and far short of anything worth storing per attempt.
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 ¶
var ErrUnknownTransport = errors.New("no transport is registered for that kind of destination")
Functions ¶
Types ¶
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
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)