Skip to main content

max / makenotwork

2.1 KB · 44 lines History Blame Raw
1 //! Bento's concrete event payload, carried on the generic
2 //! [`ops_core::eventbus`] bus. Flat `kind`-tagged so it serializes to the wire
3 //! shape the TUI parses (`{"kind":"step_start", ...}`).
4
5 use crate::domain::{AppId, Status, Step, StepRunId, Target, Version};
6 use ops_core::eventbus;
7 use serde::{Deserialize, Serialize};
8
9 pub type EventEnvelope = eventbus::EventEnvelope<Event>;
10 pub type EventTx = eventbus::EventTx<Event>;
11
12 pub fn channel() -> EventTx {
13 eventbus::channel()
14 }
15
16 pub fn emit(tx: &EventTx, event: Event) {
17 eventbus::emit(tx, event)
18 }
19
20 #[derive(Clone, Debug, Serialize, Deserialize, PartialEq)]
21 #[serde(tag = "kind", rename_all = "snake_case")]
22 pub enum Event {
23 /// A `/build` was accepted.
24 BuildRequested { app: AppId, version: Version, targets: Vec<Target> },
25 /// A previous in-flight run for this `(app, target)` was aborted because a
26 /// newer request arrived.
27 TargetAborted { app: AppId, target: Target },
28 TargetStart { app: AppId, version: Version, target: Target },
29 StepStart { run_id: StepRunId, app: AppId, version: Version, target: Target, step: Step },
30 /// A chunk of merged stdout+stderr from the step currently running.
31 /// `run_id` ties back to the `StepStart`; `seq` is a per-run monotonic
32 /// counter; `text` is UTF-8-lossy and NOT line-aligned. The on-disk log is
33 /// the byte-exact source.
34 StepLogChunk { run_id: StepRunId, seq: u32, text: String },
35 StepDone { run_id: StepRunId, app: AppId, target: Target, step: Step, status: Status },
36 TargetOk { app: AppId, version: Version, target: Target, artifacts: Vec<String> },
37 TargetFailed { app: AppId, version: Version, target: Target, step: Step, error: String },
38 /// Notarization is the one flaky, network-bound step; retries are surfaced.
39 NotarizeRetry { app: AppId, target: Target, attempt: u32, reason: String },
40 ArtifactCollected { app: AppId, target: Target, path: String, bytes: i64 },
41 PublishOk { app: AppId, target: Target, channel: String },
42 PublishFailed { app: AppId, target: Target, channel: String, error: String },
43 }
44