Skip to main content

Module wait

Module wait 

Source
Expand description

semora wait: block until feedback arrives on a document’s channel.

Joins /ws/d/{id} as an agent, collects events for a short window after the first one (so a burst arrives together), prints them, acks them, and exits 0. Exit 2 on timeout, 3 on auth errors, 4 when the document is missing. --follow --timeout N exits 0 at the timeout when it printed an event, and 2 when it did not.

The burst window holds while the server is out of reach: wait reconnects, but never sleeps past the end of the window. When it closes the burst is printed, and the ack goes over a new socket if the old one is gone. If the server stays unreachable for ACK_GRACE, one warning says the events were printed but not acked. wait knows that no ack got through to it, not that none was recorded (an ack written to a socket that then failed can have landed), so the warning says the next wait gets them again unless the ack reached the server. An ack that was written, with no sign in a second that the server read it, gets a warning of its own: it is probably in flight, and wait cannot tell that from a lost one.

A refusal on reconnect (the key revoked, access removed, the document deleted) with a burst in hand prints the burst, warns once that it was not acked, and exits 0: the events were printed. With nothing collected the refusal keeps its exit code, 3 or 4, and so does --follow, which printed every event as it came. --follow acks an event again when the server sends it again (an ack can be lost), but never prints it twice.

Functions§

run
wait_for