Documentation
¶
Overview ¶
Package relay publishes claimed outbox envelopes with bounded concurrency.
Index ¶
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrStoreRequired = errors.New("outbox/relay: store is required") ErrPublisherRequired = errors.New("outbox/relay: publisher is required") ErrPublisherPanic = errors.New("outbox/relay: publisher panicked") ErrOwnerRequired = errors.New("outbox/relay: owner is required") ErrInvalidConfig = errors.New("outbox/relay: configuration values must be positive") )
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
Owner string
BatchSize int
Workers int
LeaseDuration time.Duration
LeaseRenewalInterval time.Duration
MaxAttempts int
PollInterval time.Duration
TransitionTimeout time.Duration
Clock func() time.Time
Backoff func(attempt int) time.Duration
ClassifyError func(error) ErrorClass
Wait func(context.Context, time.Duration) error
Serialization postgres.SerializationMode
Observer outbox.Observer
Logger *slog.Logger
Heartbeat func(context.Context, time.Duration, func(context.Context) error) error
}
Config bounds one relay instance and injects deterministic policy seams.
type ErrorClass ¶
type ErrorClass uint8
ErrorClass controls whether a failed publication is retried or terminated.
const ( ErrorTransient ErrorClass = iota ErrorPermanent )
type Publisher ¶
Publisher accepts an envelope. Returning nil means the publisher accepted it, not that exactly-once delivery has been achieved.
type Relay ¶
type Relay struct {
// contains filtered or unexported fields
}
Relay coordinates claims, publisher calls, and state transitions.
func (*Relay) Readiness ¶
Readiness verifies database connectivity and, when supported, publisher connectivity. All failed checks are returned together.
type Result ¶
type Result struct {
Claimed int
Published int
Delivered int
Retried int
DeadLettered int
Released int
}
Result summarizes one bounded polling cycle.
type Store ¶
type Store interface {
Ping(context.Context) error
Claim(context.Context, postgres.ClaimRequest) ([]postgres.Claim, error)
ExtendLease(context.Context, postgres.LeaseRef, time.Duration) (time.Time, error)
MarkDelivered(context.Context, postgres.LeaseRef) error
Retry(context.Context, postgres.LeaseRef, time.Time, error) error
DeadLetter(context.Context, postgres.LeaseRef, error) error
ReleaseLease(context.Context, postgres.LeaseRef) error
}
Store is the lease-safe persistence contract used by Relay.
Click to show internal directories.
Click to hide internal directories.