blob: 654e56cb21abb7a17c3ffe59a4eb688b2661e58c (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
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,
}
|