shep-channel
Speak the shep shepherd channel from a supervised app: signal readiness, emit a metric, answer an action.
let shepherd = serve;
let = channel;
shepherd.on_action;
shepherd.on_shutdown;
shepherd.ready?;
shepherd.metric;
// Serve until the shepherd asks this app to stop.
wait_for_stop.recv.ok;
// Sending queues. Whatever the writer thread has not reached yet dies
// with the process, so drain it before exiting.
shepherd.flush?;
Ask for a channel in the Flockfile with channel = true, or get one from
wait_ready or shutdown_with_message.
Without one, every call above does nothing and the app runs unchanged, so
there is nothing to branch on. An action name you did not register still
gets a reply, which is the part an app is most likely to get wrong: to the
shepherd, silence from an app thinking hard and silence from an app that
never understood the question look the same, and only action_timeout
running out tells them apart.
flush is the call that is easiest to leave out. Sending queues, so an app
that exits from its own shutdown handler loses replies an operator is still
waiting on.
An app that runs several children of one binary can tell shep describe
which is which: shepherd.label_lamb(child.id(), LambLabel::new("worker 1")?).
The wire itself is documented in docs/shepherd-channel.md in the shep
repository. It is language agnostic, and Go, JavaScript and Python
libraries over the same contract are planned.
shep is pre-release. Anything public here can change before 1.0.
License
MIT OR Apache-2.0, at your option.