Documentation
¶
Overview ¶
Package replaybuffer selects and builds a ReplayBuffer backend from configuration and wraps it in the resilience + observability decorator stack, mirroring clients/lock. Callers depend on core/interfaces.ReplayBuffer; NewFromConfig chooses the memory (single-pod) or redis (cross-pod) backend by Kind and injects it at the composition root — swapping one for the other is a config change, never a logic edit.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func NewFromConfig ¶
func NewFromConfig(cfg *Config, client *goredis.Client) (interfaces.ReplayBuffer, error)
NewFromConfig builds the configured ReplayBuffer: it selects a backend by Kind, wraps it in the timeout + observability decorator stack (each collaborator optional/nil-safe), and returns the decorated buffer. The client is required only for KindRedis (the shared go-redis client reused from the lock/backplane); it is ignored for KindMemory. It fails loudly on a non-positive MaxSize/TTL, an unknown kind, or a redis kind with no client.
Types ¶
type Config ¶
type Config struct {
// Logger drives the logging decorator; nil skips it.
Logger interfaces.Logger
// Metrics drives the metrics decorator; nil skips it.
Metrics interfaces.Metrics
// Tracer drives the tracing decorator; nil skips it.
Tracer interfaces.Tracer
// Name labels the buffer in metrics, spans, and logs (default "replaybuffer").
Name string
// Kind selects the backend (memory | redis).
Kind Kind
// MaxSize bounds the retained messages per key.
MaxSize int
// TTL is how long a key's buffer lives after its last Append.
TTL time.Duration
// OpTimeout bounds each backend op via the timeout decorator; zero skips it.
OpTimeout time.Duration
}
Config selects and tunes the replay buffer. Kind picks the backend; MaxSize bounds the retained tail per key; TTL expires an idle key's buffer; OpTimeout bounds each backend op (zero skips the timeout decorator). Logger/Metrics/Tracer drive the observability decorators (each nil-safe).
Directories
¶
| Path | Synopsis |
|---|---|
|
Package decorators composes cross-cutting concerns — a per-op timeout and the observability trio (logging, metrics, tracing) — around any core/interfaces.ReplayBuffer, without touching the backend.
|
Package decorators composes cross-cutting concerns — a per-op timeout and the observability trio (logging, metrics, tracing) — around any core/interfaces.ReplayBuffer, without touching the backend. |
|
Package memory provides an in-process ReplayBuffer backend for single-pod deployments (dev / replica=1), where a reconnect lands on the same pod so cross-pod sharing is unnecessary.
|
Package memory provides an in-process ReplayBuffer backend for single-pod deployments (dev / replica=1), where a reconnect lands on the same pod so cross-pod sharing is unnecessary. |
|
Package redis provides a cross-pod ReplayBuffer backend over Redis, for multi-replica deployments (staging/prod) where a reconnect may land on a different pod than the one that buffered the tail.
|
Package redis provides a cross-pod ReplayBuffer backend over Redis, for multi-replica deployments (staging/prod) where a reconnect may land on a different pod than the one that buffered the tail. |