Write-behind buffer for Hindsight retain operations.
Features:
- Buffers retain calls for batch sending
- Sends batch every 5 seconds or at 50 items
- Persists buffer to disk on shutdown
- Restores buffer on startup
- Retries failed batches with exponential backoff
This ensures retain operations don't block callers and reduces the number of requests to Hindsight.
Summary
Functions
Buffers a retain operation for batch sending. Returns immediately (non-blocking).
Returns the current buffer size.
Returns a specification to start this module under a supervisor.
Flushes the buffer immediately (blocking). Used before shutdown or by CLI command.
Starts the write buffer GenServer.
Types
@type state() :: %{ buffer: [map()], timer_ref: reference() | nil, retry_count: non_neg_integer() }
Functions
Buffers a retain operation for batch sending. Returns immediately (non-blocking).
@spec buffer_size() :: non_neg_integer()
Returns the current buffer size.
Returns a specification to start this module under a supervisor.
See Supervisor.
@spec flush() :: :ok | {:error, term()}
Flushes the buffer immediately (blocking). Used before shutdown or by CLI command.
@spec start_link(keyword()) :: GenServer.on_start()
Starts the write buffer GenServer.