aboutsummaryrefslogtreecommitdiffstats
path: root/crates/daemon/src/events.rs
diff options
context:
space:
mode:
Diffstat (limited to 'crates/daemon/src/events.rs')
-rw-r--r--crates/daemon/src/events.rs44
1 files changed, 44 insertions, 0 deletions
diff --git a/crates/daemon/src/events.rs b/crates/daemon/src/events.rs
new file mode 100644
index 00000000..654e56cb
--- /dev/null
+++ b/crates/daemon/src/events.rs
@@ -0,0 +1,44 @@
+//! Daemon events.
+//!
+//! Events are the primary communication mechanism within the daemon.
+//! Components emit events to notify others of state changes, and handle
+//! events to react to changes elsewhere in the system.
+//!
+//! External processes (like CLI commands) can also inject events via the
+//! Control gRPC service.
+
+use turtle_api::history::History;
+
+/// Events that flow through the daemon's event bus.
+///
+/// Events are broadcast to all components. Each component decides which
+/// events it cares about in its `handle_event` implementation.
+#[derive(Debug, Clone, PartialEq, Eq)]
+pub(crate) enum DaemonEvent {
+ /// A command has started running.
+ HistoryStarted(History),
+
+ /// A command has finished running.
+ HistoryEnded(History),
+
+ /// Sync completed successfully.
+ SyncCompleted {
+ /// Number of records uploaded.
+ uploaded: usize,
+
+ /// Number of records downloaded.
+ downloaded: usize,
+ },
+
+ /// Sync failed.
+ SyncFailed {
+ /// Error message describing what went wrong.
+ error: String,
+ },
+
+ /// Request an immediate sync (external trigger).
+ ForceSync,
+
+ /// Request graceful shutdown of the daemon.
+ ShutdownRequested,
+}