The Survon Field Runtime is the aux extension of the Survon system. It's intended to be extremely lightweight and minimalistic, for kiosk units attached to control systems. It could be a wearable, it could be attached to a vehicle, it could be in a small shelter setup near the water pump by the shoreline.
- NOTE: This first runtime is built in
rust. Depending on how well this goes with power consumption and community adoption, etc., more runtimes may become available.
survon-base-rust/
├── Cargo.toml
├── src/
│ ├── main.rs # Core runtime: Manages modules, system updates, and orchestration
│ ├── event_bus.rs # Event Bus: Manages event publication and subscription
│ ├── orchestrator.rs # Orchestrator: Coordinates communication between modules
│ ├── tests/
│ │ └── integration.rs # Integration tests for the runtime
└── modules/
└── (empty initially)
Modules are grouped into categories, each with predefined, utility-focused events. These events scale universally and ensure consistency across modules.
- Core Events:
messageReceivedmessageSentconnectionEstablishedconnectionLost
- Utility Events:
marco(ping sent to all modules in this category)diagnostics(check module status, e.g., connection health)
- Core Events:
dataThresholdExceeded(e.g., temperature exceeds limit)dataThresholdRecovered(e.g., temperature returns to normal)dataStale(e.g., sensor data has not been updated for a while)
- Utility Events:
marco(ping for module response)diagnostics(verify all monitored sources are reporting correctly)
- Core Events:
sensorConnectedsensorDisconnectedsensorDataAvailablesensorFailure
- Utility Events:
marco(respond uniquely for each sensor, e.g., emit a test signal)diagnostics(verify sensor health and calibration)
- Core Events:
powerLowpowerRestoredpowerShutdownpowerStartup
- Utility Events:
marco(respond with power-specific acknowledgment, e.g., blink power LED)diagnostics(run checks for power supply status and battery health)
- Core Events:
systemNotification(generic system broadcast)userAlert(user-specific alert or prompt)
- Utility Events:
marco(broadcast notification acknowledgment)diagnostics(test notification delivery mechanisms)
The Survon system uses a unified event structure for communication and orchestration. Here’s the event signature:
/// Represents an event in the Survon system.
#[derive(Debug, Clone)]
pub struct Event {
pub category: String, // E.g., "com", "mon", "sen"
pub event_type: String, // E.g., "marco", "diagnostics"
pub payload: serde_json::Value, // Event-specific data
pub meta: EventMeta, // Metadata for cross-module communication
}
/// Metadata for cross-module communication and tracking.
#[derive(Debug, Clone)]
pub struct EventMeta {
pub source: String, // Module that generated the event
pub author: String, // Module's author identifier
pub timestamp: u64, // Event creation timestamp (e.g., UNIX time)
}use serde_json::json;
fn send_marco_event() -> Event {
Event {
category: "com".to_string(),
event_type: "marco".to_string(),
payload: json!({}), // No specific data needed for a ping
meta: EventMeta {
source: "orchestrator".to_string(),
author: "survon_core".to_string(),
timestamp: 1672531200,
},
}
}fn on_marco(event: &Event) -> Event {
if event.event_type == "marco" {
Event {
category: event.category.clone(),
event_type: "marcoResponse".to_string(),
payload: serde_json::json!({
"response": "Polo",
"module": "irc"
}),
meta: EventMeta {
source: "irc_module".to_string(),
author: "example_author".to_string(),
timestamp: 1672531210,
},
}
} else {
panic!("Unexpected event type: {}", event.event_type);
}
}-
Clone the Repository
git clone https://github.com/survon/runtime-base-rust.git cd runtime-base-rust -
Build the Project
cargo build
-
Run the Base Runtime
cargo run
-
Run Tests
cargo test
We welcome community contributions! Please adhere to the following:
- Follow the Module Packaging Standards when creating modules.
- Ensure all modules use the predefined event categories and comply with the event signature.
For detailed guidelines, refer to the CONTRIBUTING.md file in this repository.
Let me know if further refinement is needed!