Relay
1.x
Docs/Relay/Configuration
Open

Reading2 min
Updated31 Jul 2026
Sourcev1/concepts/configuration.mdx

Relay uses functional options for wiring dependencies and a Config struct for tuning runtime behavior.

Functional options01

The Relay struct is configured with functional options passed to relay.New():

r, err := relay.New(
    relay.WithStore(postgresStore),
    relay.WithLogger(slog.Default()),
    relay.WithConcurrency(20),
    relay.WithPollInterval(2 * time.Second),
    relay.WithBatchSize(100),
    relay.WithRequestTimeout(15 * time.Second),
    relay.WithMaxRetries(8),
    relay.WithRetrySchedule(customSchedule),
    relay.WithShutdownTimeout(60 * time.Second),
    relay.WithCacheTTL(time.Minute),
)

Available options

OptionPurposeDefault
WithStore(s)Set the persistence backend (required)--
WithLogger(l)Set the structured loggerslog.Default()
WithConcurrency(n)Number of delivery worker goroutines10
WithPollInterval(d)How often the engine checks for pending deliveries1s
WithBatchSize(n)Max deliveries dequeued per poll cycle50
WithRequestTimeout(d)HTTP timeout per delivery attempt30s
WithMaxRetries(n)Maximum delivery attempts before DLQ5
WithRetrySchedule(s)Backoff intervals between retries[5s, 30s, 2m, 15m, 2h]
WithShutdownTimeout(d)Max wait for in-flight deliveries on shutdown30s
WithCacheTTL(d)TTL for the catalog's in-memory cache (0 = no cache)30s

Config struct02

type Config struct {
    Concurrency     int
    PollInterval    time.Duration
    BatchSize       int
    RequestTimeout  time.Duration
    MaxRetries      int
    RetrySchedule   []time.Duration
    ShutdownTimeout time.Duration
    CacheTTL        time.Duration
}

Default retry schedule03

var DefaultRetrySchedule = []time.Duration{
    5 * time.Second,
    30 * time.Second,
    2 * time.Minute,
    15 * time.Minute,
    2 * time.Hour,
}

After all retries are exhausted, the delivery moves to the DLQ.

Required options04

The only required option is WithStore(). Without a store, relay.New() returns ErrNoStore.