pub fn sum<T: Add<Output = T> + Copy + Named + 'static>() -> impl Accumulator<State = T, Update = T>Expand description
Accumulate the sum of received updates.
§Note: Not a CRDT
This accumulator is not idempotent and is therefore not suitable for distributed scatter/gather patterns with at-least-once delivery semantics. Duplicate updates will be counted multiple times:
sum(1, 2, 2, 3) = 8 (expected 6 if second 2 is duplicate)§When to use:
- Single-source accumulation with exactly-once delivery
- Local (non-distributed) aggregation
- When upstream deduplication is guaranteed
§CRDT Alternative:
For distributed use cases, consider using a GCounter CRDT instead, which tracks per-replica increments and uses pointwise-max for merging (commutative, associative, and idempotent).