Skip to main content

Module machine

Module machine 

Source
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.

stateentered onnext try
signed_outno MuxBus sign-ina sign-in (a local recheck every minute, no request)
publishingthe record was storeda minute, or a change of the snapshot
retryingunreachable, 5xx, 429, any other status5 s doubling to 5 min, full jitter; a 429’s Retry-After
unsupported404, no presence routeabout 5 min; at once on a sign-in, a network change, a wake, or a new relay version
rejected400 or 41010 min or more
signed_offa goodbye was stored at a sign-outa sign-in
offthis 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.