Skip to main content

Module peer_hold

Module peer_hold 

Source
Expand description

A message to an agent of a LAN peer that is down is kept on the sender’s instance for 24 hours and delivered when the peer answers again, as a message to a stopped local agent is. Before this it went to the cloud relay, which drops it after 30 minutes if no install of the account picks it up; a machine that was off for an hour lost it (task #2228).

The agent counts as a known peer’s when a LAN peer listed it (backend::lan::seen_agents, kept across restarts) and that peer no longer answers its poll. A peer that does answer is left to the old path: it can start a stopped agent when the message reaches it, which a held copy here cannot. The relay keeps the message when it says another install of the account runs the agent, or cannot say (absent_route_for), as for a local agent that is absent.

The row lives in db_jekt_held under the target key peer:<route name>, which no agent UID can be, so the replay for local agents never sees it.

EnumsΒ§

Sent πŸ”’
What one held message came to on a replay pass.

ConstantsΒ§

AGENTS_PER_PASS πŸ”’
LOOKUPS_PER_PASS πŸ”’
Agents one replay pass looks at (their machine may be down, which costs only a cached lookup), agents it sends to, and messages it sends to one.
MAX_REFUSALS πŸ”’
Refusals by a peer that has the agent, before a held message is dropped (as for a local agent).
PEER_KEY_PREFIX πŸ”’
The target key of a message held for a peer’s agent.
POLL_FRESH_SECS πŸ”’
A peer whose last answered poll is older than this is not answering (polls run every 30 s).
ROWS_PER_AGENT πŸ”’

FunctionsΒ§

down_host πŸ”’
The host that listed the agent, when no live LAN peer of that name answers its poll now.
hold_for_down_peer πŸ”’
Hold req for an agent of a LAN peer that is down. None leaves it to the relay and the other holds: the hold does not apply to this sender, the agent is not a known peer’s, its machine is answering, it is defined here, or the relay has it.
hold_for_peer πŸ”’
The hold itself, for hold_for_down_peer and hold_for_silent_peer.
hold_for_silent_peer πŸ”’
Hold req for an agent of a LAN peer that answers its polls but gave no answer to this message (its inbound check was stuck behind a cloud login refresh that never returned). The replay sends it again; the peer that receives it can still start a stopped agent, which this copy cannot.
late_message πŸ”’
message with the note that it was sent earlier, when it has waited long enough to need one.
peer_key πŸ”’
relay_has_it πŸ”’
Whether the relay should take the message for name instead: another install of the account runs it, or the relay cannot say (an older one). A relay that is not reachable, or a sender not signed in to it, has nothing to offer, so the message is kept here.
replay_pass πŸ”’
One pass over the messages held for peers’ agents: each agent now on the LAN gets its messages, oldest first; one the relay has (another install runs it) goes there. Run beside the replay for local agents, whose pass also drops what expired.
request_for πŸ”’
The request a held row is sent as: addressed by the name the sender used, late messages marked.
rotated πŸ”’
keys starting at the by-th, so each pass looks first at a different agent.
send_over_lan πŸ”’
send_over_relay πŸ”’
send_row πŸ”’
One held message, sent over the LAN (lan) or the relay, unless it ran out while the pass was asking where its agent is or sending the ones before it. The peer that receives it cannot tell.
settle πŸ”’
spent πŸ”’
Whether a row’s 24 h hold, or the sender’s own deadline, has run out: it is dropped, not sent.