Skip to main content

systemprompt_traits/startup_events/
types.rs

1//! Startup event type definitions.
2//!
3//! Copyright (c) systemprompt.io — Business Source License 1.1.
4//! See <https://systemprompt.io> for licensing details.
5
6use std::time::Duration;
7
8#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
9pub enum Phase {
10    PreFlight,
11    Database,
12    McpServers,
13    ApiServer,
14    Agents,
15    Scheduler,
16}
17
18impl Phase {
19    pub const fn name(&self) -> &'static str {
20        match self {
21            Self::PreFlight => "Pre-flight",
22            Self::Database => "Database",
23            Self::McpServers => "MCP Servers",
24            Self::ApiServer => "API Server",
25            Self::Agents => "Agents",
26            Self::Scheduler => "Scheduler",
27        }
28    }
29
30    pub const fn is_blocking(&self) -> bool {
31        matches!(
32            self,
33            Self::PreFlight | Self::Database | Self::McpServers | Self::ApiServer
34        )
35    }
36}
37
38#[derive(Debug, Clone, Copy, PartialEq, Eq)]
39pub enum ServiceType {
40    Mcp,
41    Agent,
42    Api,
43    Scheduler,
44}
45
46impl ServiceType {
47    pub const fn label(&self) -> &'static str {
48        match self {
49            Self::Mcp => "MCP",
50            Self::Agent => "Agent",
51            Self::Api => "API",
52            Self::Scheduler => "Sched",
53        }
54    }
55}
56
57#[derive(Debug, Clone, Copy, PartialEq, Eq)]
58pub enum ServiceState {
59    Starting,
60    Running,
61    Stopped,
62    Failed,
63}
64
65#[derive(Debug, Clone)]
66pub struct ServiceInfo {
67    pub name: String,
68    pub service_type: ServiceType,
69    pub port: Option<u16>,
70    pub state: ServiceState,
71    pub startup_time: Option<Duration>,
72}
73
74#[derive(Debug, Clone)]
75pub struct ModuleInfo {
76    pub name: String,
77    pub category: String,
78}