Owners base - NexusTomorrow/server GitHub Wiki
The owner base every owner runs on, and the watchdog that reports a stalled one. How owners fit the server is on Owners.
The owner base
An owner is a class holding one side of the game, run by one background thread that drains one message queue.
| Operation | Does |
|---|---|
| Posting | Puts a message on the queue and returns at once; refused once the owner is stopping |
| Stopping | Closes the queue, so what's already queued still drains. An owner stopped before it started can't be started afterwards, and starting one twice is an error |
| A reply | Travels back in the message itself: the owner completes it, and the caller carries on outside the owner's thread |
| A handler that throws | Is logged; the owner answers the caller with a refusal or drops the session that sent it, and the next message runs. A failure while reporting the fault can't stop the thread either |
Anything that needs the database goes to the write-behind queue as work and comes back as a completion message (Persistence).
The watchdog
| Holds | Value |
|---|---|
| How often it checks | Once a second, on the host's clock |
| What it asks | How many messages each owner has handled |
| What it reports | An owner with messages waiting that hasn't handled one for 10 seconds, logged as stalled, and again while it lasts |
| What it never does | Stop or restart an owner |
In the test harness, an owner that stalls fails the scenario that stalled it.
Known edges
- The watchdog reports only an owner with messages waiting, so a handler stuck with an empty queue behind it goes unseen.
- The watchdog's second and its 10-second stall are fixed in code.
Where the code lives
| Piece | Path |
|---|---|
| The owner base, the watchdog and the session interface | Source/NexusTomorrow.Owners/ |
| The watchdog's timer | Source/NexusTomorrow.Server/OwnerWatchdogService.cs |
| The harness's stall check | Tests/NexusTomorrow.Harness/HarnessServer.cs |
| Tests | Tests/NexusTomorrow.Owners.Tests/ |