Expand description
The presence publisher’s decisions, apart from its I/O. Given what just
happened (Event) and the time (Now), Machine::next settles the
state, says what to do (Action) and how long to wait before the next
Event::Due. Nothing here reads a clock, a random number or the
network, so every rule is tested with a fake clock; super::Driver runs
it against the relay.
| state | entered on | next try |
|---|---|---|
signed_out | no MuxBus sign-in | a sign-in (a local recheck every minute, no request) |
publishing | the record was stored | a minute, or a change of the snapshot |
retrying | unreachable, 5xx, 429, any other status | 5 s doubling to 5 min, full jitter; a 429’s Retry-After |
unsupported | 404, no presence route | about 5 min; at once on a sign-in, a network change, a wake, or a new relay version |
rejected | 400 or 410 | 10 min or more |
signed_off | a goodbye was stored at a sign-out | a sign-in |
off | this install doesn’t publish (super::policy) | turned on |
Outside publishing a change of the snapshot only marks it dirty: the
next try sends the latest one, no sooner. A 409 means the relay already
has a newer record of this install’s, which is as good as storing this
one.
A goodbye (a v3 record, gone) is due when something was published and
the relay takes v2 or later (Machine::farewell): an older relay would
refuse v3, so it gets none. Turning publishing off says it here
(Action::Goodbye); a sign-out and a quit say it from outside, and a
sign-out tells the machine with Event::Goodbye.
Two refusals get an immediate second try before rejected: a record the
relay can’t parse is sent again one version down, v4 then v2 then v1 (an
older relay knows no agent lines, an older one still no states), and the
version it took is then kept for that relay for Config::v1_memory; a
record whose time the relay refuses is sent again stamped with the
relay’s clock, learned from the Date of every answer.
Structs§
- Config 🔒
- The waits, apart so tests can shorten them.
- Farewell 🔒
- A goodbye is due, stamped on the relay’s clock as far as it is known.
- Followups 🔒
- The second tries already spent on the record being sent.
- Log 🔒
- Machine 🔒
- Now 🔒
- The time, as the driver read it.
mono_msonly ever grows and drives the waits;wall_msis this computer’s clock, for the status and the record;randis uniform in[0, 1), for jitter. - Step 🔒
Enums§
Constants§
- CLOCK_
NOTE_ 🔒AFTER_ MS - A clock further than this from the relay’s is shown in the status.
- LIVE 🔒
- LIVE_
VERSION 🔒 - The version a fresh try sends to a relay not known to be older.
- MALFORMED_
RECORD 🔒 - The relay’s
errorfor a record it can’t parse, which is what a relay that predates the record’s version answers.