v0.3.15-pre.005
This commit is contained in:
83
crates/ksp-app-raw-transaction-ingest-desk/src/dto_route.rs
Normal file
83
crates/ksp-app-raw-transaction-ingest-desk/src/dto_route.rs
Normal file
@@ -0,0 +1,83 @@
|
||||
// file: crates/ksp-app-raw-transaction-ingest-desk/src/dto_route.rs
|
||||
// version: 1
|
||||
|
||||
//! Safe route-identity and lifecycle-state foundation for Raw Transaction Ingest Desk.
|
||||
|
||||
use ts_rs::TS; // rust-rules: trait-import
|
||||
|
||||
/// Stable logical V1 route identifiers owned by Raw Transaction Ingest Desk.
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq, serde::Serialize, TS)]
|
||||
#[serde(rename_all = "kebab-case")]
|
||||
#[ts(export, export_to = "../frontend/ts/bindings/ksp_app_raw_transaction_ingest_desk/dto_route/RawIngestRouteId.ts")]
|
||||
pub(crate) enum RawIngestRouteId {
|
||||
/// Yellowstone Subscribe plus same-network HTTP hydration.
|
||||
YellowstoneHydrated,
|
||||
/// Standard Solana logs subscription plus same-network HTTP hydration.
|
||||
StandardLogsHydrated,
|
||||
/// Standard Solana block subscription with direct RAW projection.
|
||||
StandardBlockDirect,
|
||||
/// Helius transaction subscription plus same-network HTTP hydration.
|
||||
HeliusTransactionHydrated,
|
||||
/// HTTP block polling and direct block material projection.
|
||||
HttpBlockPolling,
|
||||
}
|
||||
|
||||
impl crate::RawIngestRouteId {
|
||||
/// Returns all V1 route identifiers in stable UI order.
|
||||
#[must_use]
|
||||
pub(crate) fn all() -> std::vec::Vec<Self> {
|
||||
return vec![Self::YellowstoneHydrated, Self::StandardLogsHydrated, Self::StandardBlockDirect, Self::HeliusTransactionHydrated, Self::HttpBlockPolling];
|
||||
}
|
||||
}
|
||||
|
||||
/// Stable Raw Transaction Ingest Desk route lifecycle states.
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq, serde::Serialize, TS)]
|
||||
#[serde(rename_all = "snake_case")]
|
||||
#[ts(export, export_to = "../frontend/ts/bindings/ksp_app_raw_transaction_ingest_desk/dto_route/RawIngestRouteState.ts")]
|
||||
pub(crate) enum RawIngestRouteState {
|
||||
/// Required Config composition is incomplete or incoherent.
|
||||
Unavailable,
|
||||
/// Config proves composability but no runtime Worker is active.
|
||||
Configured,
|
||||
/// Runtime resources are being revalidated and assembled.
|
||||
Starting,
|
||||
/// One Worker instance is active for the logical route.
|
||||
Running,
|
||||
/// Stop has been requested and bounded termination is pending.
|
||||
Stopping,
|
||||
/// The route Worker terminated normally and its handle was removed.
|
||||
Stopped,
|
||||
/// Start or runtime failed with a safe projected code.
|
||||
Faulted,
|
||||
}
|
||||
|
||||
impl crate::RawIngestRouteState {
|
||||
/// Returns all lifecycle states in stable presentation order.
|
||||
#[must_use]
|
||||
pub(crate) fn all() -> std::vec::Vec<Self> {
|
||||
return vec![Self::Unavailable, Self::Configured, Self::Starting, Self::Running, Self::Stopping, Self::Stopped, Self::Faulted];
|
||||
}
|
||||
}
|
||||
|
||||
/// Static route/state foundation exposed by the scaffold before Config route inventory exists.
|
||||
#[derive(Clone, Debug, serde::Serialize, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export, export_to = "../frontend/ts/bindings/ksp_app_raw_transaction_ingest_desk/dto_route/RawIngestRouteFoundationDto.ts")]
|
||||
pub(crate) struct RawIngestRouteFoundationDto {
|
||||
/// Five stable V1 logical route identifiers; this is not a composability claim.
|
||||
pub(crate) route_ids: std::vec::Vec<crate::RawIngestRouteId>,
|
||||
/// Stable lifecycle state vocabulary reserved for later runtime projections.
|
||||
pub(crate) states: std::vec::Vec<crate::RawIngestRouteState>,
|
||||
}
|
||||
|
||||
impl crate::RawIngestRouteFoundationDto {
|
||||
/// Builds the static scaffold contract without resolving endpoints, secrets or Worker resources.
|
||||
#[must_use]
|
||||
pub(crate) fn scaffold() -> Self {
|
||||
return Self { route_ids: crate::RawIngestRouteId::all(), states: crate::RawIngestRouteState::all() };
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
#[path = "../unit_tests/dto_route.rs"]
|
||||
mod tests;
|
||||
Reference in New Issue
Block a user