aboutsummaryrefslogtreecommitdiffstats
path: root/crates/daemon/src/events.rs
blob: 3b6fa5d8bfb1d35f7d2e5cfc2337d236163a04cc (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
45
46
47
48
//! 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::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)]
pub(crate) enum DaemonEvent {
    // ---- History lifecycle ----
    /// A command has started running.
    HistoryStarted(History),

    /// A command has finished running.
    HistoryEnded(History),

    /// Sync completed successfully.
    SyncCompleted {
        /// Number of records uploaded.
        #[expect(unused)]
        uploaded: usize,

        /// Number of records downloaded.
        #[expect(unused)]
        downloaded: usize,
    },

    /// Sync failed.
    SyncFailed {
        /// Error message describing what went wrong.
        error: String,
    },

    /// Request an immediate sync (external trigger).
    ForceSync,

    // ---- Lifecycle ----
    /// Request graceful shutdown of the daemon.
    ShutdownRequested,
}