rmap: add TTL support + clean up sink consumer maps #66
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What
This adds TTL support to Pulse replicated maps (
rmap) and wires it into streaming sinks to prevent leaked per-stream sink metadata.rmap TTL
rmap.WithTTL(ttl)sets an absolute TTL on the backing Redis hash (usesEXPIRENX).rmap.WithSlidingTTL(ttl)sets a sliding TTL (refreshed on every write).streaming sinks
streaming.Streamis configured with a TTL,streaming.Sinkapplies the same TTL policy to the per-stream consumers map (stream:<name>:sinks), preventingmap:stream:*leaks for TTL’d ephemeral streams.stream deletion hygiene
Stream.Destroy()now also clears the per-stream consumers map hash and publishesreset:*on the map channel, mirroringrmap.Destroysemantics.Docs: updated
rmap/README.mdwith the new TTL options.Why
In prod we observed a large number of stale
map:stream:result:*keys (sink metadata) persisting long after the corresponding result streams were gone. This change makes retention a first-class concept for replicated maps and ties map retention to stream retention for the sink metadata path.Test evidence
go test ./streaming/options -run TestStreamOptionsgo test ./streaming -run TestOptions(Full rmap/streaming TTL tests require Redis; CI covers those.)