Documentation
¶
Overview ¶
Package dedup implements a fixed-capacity LRU set used by the bus to suppress duplicate events that the DingTalk Stream SDK redelivers on reconnect (see plan invariant #2). The set stores only keys, never values, and is safe for concurrent use by multiple goroutines.
Index ¶
Constants ¶
const DefaultCapacity = 8192
DefaultCapacity is the default LRU size when LRU is constructed without an explicit capacity. 8192 is sized to absorb a typical reconnect-storm window (~5 min × 30 events/s) while staying memory-cheap (~256 KB at 32 bytes/key).
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type LRU ¶
type LRU struct {
// contains filtered or unexported fields
}
LRU is a fixed-capacity LRU set of string keys. Zero value is not usable; call New or NewWithCapacity.
func NewWithCapacity ¶
NewWithCapacity returns an LRU sized to hold up to cap keys. cap must be > 0.
func (*LRU) Seen ¶
Seen reports whether key was already present and inserts it if not. The return value is true when the caller should treat the event as a duplicate (drop it) and false when this is the first occurrence.
Empty keys are never considered duplicates and are not stored — callers without a stable identifier should use RawEvent.DedupKey() which falls back to a content hash.