#[non_exhaustive]pub enum BusEvent {
Process {
event: ProcessEventKind,
info: ProcessInfo,
manually: bool,
at_ms: u64,
},
LogOut {
id: u32,
line: String,
},
LogErr {
id: u32,
line: String,
},
Channel {
id: u32,
message: ChildMessage,
},
Dropped {
count: u64,
},
DaemonShutdown,
DogConfigChanged {
dog: String,
},
}Expand description
One event on the daemon bus
Uses adjacently tagged serde format with event discriminator and data wrapper.
Subscription TOPICS are the dotted strings from BusEvent::topic
(process.exit, log.out, daemon.* — spec §6 grammar).
The daemon’s server-side filter globs against topic().
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Process
Lifecycle event for one sheep
LogOut
One stdout line from a sheep
LogErr
One stderr line from a sheep
Channel
One message a sheep wrote on its shepherd channel (fd 3).
Child->shepherd only. The shepherd’s own writes — the
{"kind":"shutdown"} of shutdown_with_message, and an action a
Trigger dispatched — are deliberately not here. Every one of them is
something an operator or the daemon just did and already has a
reporter: a shutdown message is followed by process.stop, and an
action is answered to the caller that sent it by
Response::Triggered. Putting them here as well would make this the
only event on the bus reporting a REQUEST rather than an outcome, and
would loop a dog that both subscribes and triggers back onto its own
dispatches. Adding the outbound half later stays additive — another
variant, more channel. topics, no version bump — so this is a
narrowing, not a door closed.
message is the app’s own text, whole and unredacted, unlike the
[dog.<name>] config that travels as DogSectionToml. Nothing on
this wire is a credential: Ready is empty, Metric is a name and a
float, and an ActionReply body is text the app chose to publish to
whoever triggered it. That is what makes a derived Debug safe here.
Fields
message: ChildMessageThe message, exactly as it came off fd 3.
Dropped
The bounded queue dropped this many events for this subscriber
DaemonShutdown
Daemon is shutting down
DogConfigChanged
A dog’s section in dogs.toml changed. Published under
config.dog.<name>, so a dog subscribes to its own name and hears
nobody else’s.
Says THAT it changed and nothing about what it means. A dog that
wants the values re-asks with
Request::DogConfig and
decides for itself what to do with them: swap values in place,
rebind a listener, or ask for its own restart. Putting a live
versus needs-restart axis here would mean shep knowing what a
third-party dog’s fields mean, which is the one thing this whole
contract refuses.
§What it carries, and what it must never carry
A NAME, and nothing else. The bus is a broadcast: a config.*
subscriber sees every dog’s frames, and a [bark] section
routinely holds a webhook URL that is itself a bearer credential,
which is why DogSectionToml redacts its own Debug.
Request::DogConfig answers a dog for its OWN section, so
re-asking is the whole design rather than an extra round trip. A
derived Debug is safe here for the same reason: a dog’s name is
what an operator typed into enabled_dogs.
Implementations§
Source§impl BusEvent
impl BusEvent
Sourcepub fn topic(&self) -> Cow<'static, str>
pub fn topic(&self) -> Cow<'static, str>
The dotted subscription topic for this event (spec §6 grammar)
A Cow rather than a &'static str, because one topic is not
fixed: Self::DogConfigChanged names its dog in the topic
itself, which is what lets a dog subscribe to its own config and
hear nobody else’s. Every other variant is still a borrowed
literal and allocates nothing.