Skip to main content

photon_runtime/admin/
types.rs

1//! Serde DTOs for host ops introspection (JSON mapping in product facades).
2
3use serde::{Deserialize, Serialize};
4use serde_json::Value;
5
6/// Topic catalog entry from the compile-time [`TopicRegistry`](photon_backend::TopicRegistry).
7#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
8pub struct AdminTopicSummary {
9    /// Stable topic name (e.g. `user.notifications`).
10    pub topic_name: String,
11    /// JSON payload field used as partition key, when keyed.
12    pub keyed_by: Option<String>,
13    /// Parsed topic schema JSON.
14    pub schema_json: Value,
15}
16
17/// Inventory entry for a `#[photon::subscribe]` handler.
18#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
19pub struct AdminHandlerSummary {
20    /// Topic this handler listens on.
21    pub topic_name: String,
22    /// Durable subscription name (`None` for consumer-group handlers).
23    pub subscription_name: Option<String>,
24    /// Consumer group id when load-balanced (`None` for durable handlers).
25    pub consumer_group: Option<String>,
26    /// Stable registry key from inventory.
27    pub registry_key: String,
28    /// Delivery mode: `"durable"` or `"consumer_group"`.
29    pub mode: String,
30}
31
32/// Last committed sequence for a subscription/topic partition.
33#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
34pub struct AdminCheckpointSummary {
35    /// Subscription or consumer-group id used for checkpoint storage.
36    pub subscription_name: String,
37    /// Topic name.
38    pub topic_name: String,
39    /// Optional partition or virtual-shard key.
40    pub topic_key: Option<String>,
41    /// Last committed sequence, if a checkpoint exists.
42    pub last_seq: Option<i64>,
43}
44
45/// Storage adapter capabilities surfaced for admin UIs.
46#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
47pub struct AdminBackendSummary {
48    /// Stable telemetry label (`mem`, `nats`, …).
49    pub telemetry_label: String,
50    /// Whether [`Photon::get_event`](crate::Photon::get_event) is supported.
51    pub supports_get_event: bool,
52    /// Maximum replay window in seconds for bounded retention adapters.
53    pub max_replay_window_secs: Option<u64>,
54}
55
56/// Point-in-time ops introspection snapshot (read-only).
57#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)]
58pub struct AdminSnapshot {
59    /// Installed backend capabilities.
60    pub backend: AdminBackendSummary,
61    /// Registered topics from `#[photon::topic]`.
62    pub topics: Vec<AdminTopicSummary>,
63    /// Registered handlers from `#[photon::subscribe]`.
64    pub handlers: Vec<AdminHandlerSummary>,
65    /// Checkpoint cursors for inventory handlers.
66    pub checkpoints: Vec<AdminCheckpointSummary>,
67}