Skip to content

ADR: Resilient client (NATS-style reconnect)

Accepted — implemented in pkg/client/resilience.

Chronacta gRPC clients previously relied on application code copying dialWithRetry from docs/examples. Event-store products often document Polly-style manual retry. NATS clients reconnect transparently at the connection layer.

Introduce pkg/client/resilience with:

  • ResilientClient: long-lived connection, infinite reconnect with backoff (default MaxReconnects = -1, ReconnectWait = 1s), gRPC keepalive.
  • LiveSubscription: auto-resubscribe transient streams from last delivered position after stream or transport errors.
  • DurableWorker: pull/ack loop with reconnect pause; checkpoint remains on the server.

Append auto-retry is enabled only when IdempotencyKey is set (same semantics as idempotent append on the server).

Low-level client.Dial remains available for tests and minimal tools.

  • Applications call resilience.Connect once at startup.
  • Docs and examples use resilience as the primary path; copied dialWithRetry is legacy.
  • REST/TypeScript/Python clients are unchanged (no durable subscription surface).