Module stream

Module stream 

Source
Expand description

Redis Stream consumer for CDC events.

Tails a peer’s cdc stream and parses events.

§Stream Trimming

Redis streams can be trimmed via MAXLEN or MINID to bound memory. If our cursor points to an entry older than the oldest in the stream, we’ve “fallen behind” and missed events. This module detects this and returns a StreamTrimmed result so callers can:

  • Log a warning (potential data gap)
  • Reset cursor to oldest available entry
  • Emit a metric for alerting

§Content Hash Validation

When a PUT event includes a hash field, we verify that the SHA256 of the decompressed data matches. This detects corruption from:

  • Network bit flips
  • Compression bugs
  • Malicious peers

Structs§

CdcEvent
A parsed CDC event from the stream.
CdcMeta
Metadata from a CDC PUT event.
StreamTailer
Stream tailer for a single peer’s CDC stream.

Enums§

CdcOp
CDC operation type.
ReadResult
Result of reading from a stream, accounting for trim scenarios.

Functions§

calculate_lag_ms
Calculate the time lag in milliseconds between two stream IDs.
compare_stream_ids
Compare two Redis stream IDs.
maybe_decompress
Decompress zstd data if it has the magic header, otherwise return as-is.
parse_stream_id_timestamp
Parse the timestamp (milliseconds since epoch) from a stream ID.