shep-channel 0.6.3

Client for the shep shepherd channel: readiness, metrics and custom actions over the descriptor shep hands a supervised process
Documentation

shep-channel

Speak the shep shepherd channel from a supervised app: signal readiness, emit a metric, answer an action.

let shepherd = shep_channel::serve();
let (stop, wait_for_stop) = std::sync::mpsc::channel();

shepherd.on_action("gc", |params, _name| {
    format!("collected, params={params:?}")
});
shepherd.on_shutdown(move || {
    let _ = stop.send(());
});
shepherd.ready()?;
shepherd.metric("rps", 4200.0);

// Serve until the shepherd asks this app to stop.
wait_for_stop.recv().ok();

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.

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.