Vixen
02b45cc4
csharp
public sealed class RealmDirectory

The only place a realm ever calls the control plane. ADR-016's rule, made a type.

Read the guide page for this →

Remarks

Orleans is asked, not awaited. A grain call is a network round trip with a scheduler in front of it: a frame that awaits one has a p99 measured in milliseconds and a p99.9 measured in seconds. So a realm posts a request, keeps simulating, and applies the answer at a defined point in a later frame — which is this class. One inbox, one outbox, drained once per update.

This is not a new pattern in this repository. ISessionAuthenticator is already shaped exactly this way — answering Pending and being asked again next update — and doc 16 records why: "a completion on a thread-pool thread would make every layer it touches thread-safe for the sake of an event that happens twice a minute". This is that pattern with a bigger surface.

⚠ The apply callback runs on the realm's thread, inside Drain. That is the entire value of the type: everything it touches — the world, the session, the admission list — is single-threaded, and stays that way. The call delegate runs wherever the task ran, and must touch none of them.

⚠ Nothing here knows what a grain is. L0 has no orchestrator and this class is still the right shape, because what it enforces is the threading discipline rather than the transport. L1 hands the call an IGrainFactory; the drain does not change.

Fields and properties (3)

  • public int Pending

    How many questions are outstanding.

  • public long AnsweredCount

    How many answers have been applied.

  • public long FaultedCount

    How many questions came back as an exception.

Methods (3)

  • public void Ask<TAnswer>(Func<CancellationToken, Task<TAnswer>> call, Action<TAnswer> apply, Action<Exception>? onFault = null)

    Asks something, and says what to do with the answer.

  • public int Drain()

    Applies every answer that has arrived since the last time.

  • public void Dispose()

    Stops asking, and abandons what is outstanding.

Used by (4)

  • RealmClusterVixen.Live.Realm.Cluster
  • RealmClusterTestsVixen.Live.Realm.Cluster.Tests
  • RealmDirectoryTestsVixen.Live.Realm.Tests
  • RealmHostVixen.Live.Realm