Nebula
Worker

AuthorityCallLedger

The call ids a worker has applied, so a call that arrives twice runs once (design D5).

generated from the sources
public sealed class AuthorityCallLedger

The call ids a worker has applied, so a call that arrives twice runs once (design D5). Bounded two ways: at most Capacity ids are remembered, oldest forgotten first, and an id older than TtlTicks ticks is forgotten on the next Expire. A duplicate of a forgotten call would be applied again; the bounds say how long "at most once" is enforced for.

Constructors

AuthorityCallLedger

public AuthorityCallLedger(int capacity = DefaultCapacity, uint ttlTicks = DefaultTtlTicks);

Fields

DefaultCapacity

public const int DefaultCapacity = 4096;

Ids remembered per worker by default: 4096, a few seconds of busy cross-worker traffic.

DefaultTtlTicks

public const uint DefaultTtlTicks = 600;

Ticks an id is remembered by default: 600, ten seconds at 60 ticks per second.

Properties

Capacity

public int Capacity { get; }

The most ids remembered at once.

TtlTicks

public uint TtlTicks { get; }

How many ticks an id stays remembered.

Count

public int Count { get; }

Ids currently remembered.

Duplicates

public long Duplicates { get; }

Calls refused as duplicates since the ledger was created.

Evictions

public long Evictions { get; }

Ids forgotten because the ledger was full, since it was created.

Methods

TryRecord

public bool TryRecord(ulong callId, uint tick);

Record that callId is being applied at tick. False when the id is already remembered: the caller must not apply it. Recording past Capacity forgets the oldest id.

Contains

public bool Contains(ulong callId);

Whether callId is remembered as applied.

Expire

public void Expire(uint tick);

Forget every id recorded more than TtlTicks ticks before tick. Call once a tick.

Clear

public void Clear();

Forget everything.

On this page