Builtin Library
README.md
shared Module
Helpers more than one tool in the client toolbox uses. A tool inside
this toolbox pulls them in with require(".shared").
Purpose
A sub-client starts in the background: its row reads starting until
it can answer, then ready, or failed with its reason. The create
and restart tools wait on that row through awaitStarted, so a caller
can wait for the sub-client it just started before its first call.
Usage
local Shared = require(".shared")
-- `request` sends one op to the sub-client host and returns its row.
local row = Shared.awaitStarted(request, id, 60)
if row.state == "failed" then
error("client: " .. tostring(row.reason))
end
Exports
Shared.awaitStarted(request, id?, timeoutSeconds?): reads the row of the sub-clientidnames (the caller's own whenidis nil) every 0.25 s until it leavesstarting, and returns the row it ended on. Raises naming the sub-client, the time waited and its reason when it is still starting aftertimeoutSeconds.Shared.DEFAULT_TIMEOUT_SECONDS: the wait used when the caller states none, 20 minutes.