ExWapp.Session.RetryCounters (ExWapp v0.1.2)

Copy Markdown View Source

Bounded bookkeeping for the per-message retry counters in the session state.

A counter is added for every inbound message that fails to decrypt and for every outbound retry or session repair, and nothing ever resolves them — deliberately, since clear_pending_requests must not forget attempt counts across a reconnect. Without a cap, a peer with a desynced session grows the session's heap by one permanent map entry per undecryptable message and the repair path scans all of them on every rejected ack.

Keys are evicted oldest-first once the cap is reached. Losing an old counter merely re-opens a handful of extra retries for a message that has long been resolved, whereas an unbounded map grows for the life of the process.

Summary

Functions

Sets key to count in the state's :retry_counters, evicting the oldest counters beyond the cap.

Functions

put(state, key, count)

@spec put(map(), String.t(), pos_integer()) :: map()

Sets key to count in the state's :retry_counters, evicting the oldest counters beyond the cap.