bootstrap workspace
Authored by
mfwolffe <wolffemf@dukes.jmu.edu>
- SHA
52ba8f585a0d36fd1907bbbd63c2fbbed7c90ff9- Parents
-
9558cc4 - Tree
8cf19aa
52ba8f5
52ba8f585a0d36fd1907bbbd63c2fbbed7c90ff99558cc4
8cf19aa| Status | File | + | - |
|---|---|---|---|
| A |
Cargo.lock
|
21 | 0 |
| A |
Cargo.toml
|
20 | 0 |
| A |
garwarp-ipc/Cargo.toml
|
6 | 0 |
| A |
garwarp-ipc/src/lib.rs
|
45 | 0 |
| A |
garwarp/Cargo.toml
|
7 | 0 |
| A |
garwarp/src/main.rs
|
5 | 0 |
| A |
garwarpctl/Cargo.toml
|
7 | 0 |
| A |
garwarpctl/src/main.rs
|
5 | 0 |
Cargo.lockadded@@ -0,0 +1,21 @@ | ||
| 1 | +# This file is automatically @generated by Cargo. | |
| 2 | +# It is not intended for manual editing. | |
| 3 | +version = 4 | |
| 4 | + | |
| 5 | +[[package]] | |
| 6 | +name = "garwarp" | |
| 7 | +version = "0.1.0" | |
| 8 | +dependencies = [ | |
| 9 | + "garwarp-ipc", | |
| 10 | +] | |
| 11 | + | |
| 12 | +[[package]] | |
| 13 | +name = "garwarp-ipc" | |
| 14 | +version = "0.1.0" | |
| 15 | + | |
| 16 | +[[package]] | |
| 17 | +name = "garwarpctl" | |
| 18 | +version = "0.1.0" | |
| 19 | +dependencies = [ | |
| 20 | + "garwarp-ipc", | |
| 21 | +] | |
Cargo.tomladded@@ -0,0 +1,20 @@ | ||
| 1 | +[workspace] | |
| 2 | +members = [ | |
| 3 | + "garwarp", | |
| 4 | + "garwarp-ipc", | |
| 5 | + "garwarpctl", | |
| 6 | +] | |
| 7 | +resolver = "2" | |
| 8 | + | |
| 9 | +[workspace.package] | |
| 10 | +edition = "2024" | |
| 11 | +license = "MIT" | |
| 12 | +version = "0.1.0" | |
| 13 | + | |
| 14 | +[workspace.lints.rust] | |
| 15 | +unsafe_code = "forbid" | |
| 16 | + | |
| 17 | +[workspace.lints.clippy] | |
| 18 | +pedantic = "warn" | |
| 19 | +unwrap_used = "warn" | |
| 20 | +expect_used = "warn" | |
garwarp-ipc/Cargo.tomladded@@ -0,0 +1,6 @@ | ||
| 1 | +[package] | |
| 2 | +name = "garwarp-ipc" | |
| 3 | +version = "0.1.0" | |
| 4 | +edition = "2024" | |
| 5 | + | |
| 6 | +[dependencies] | |
garwarp-ipc/src/lib.rsadded@@ -0,0 +1,45 @@ | ||
| 1 | +pub const PROTOCOL_VERSION: u16 = 1; | |
| 2 | + | |
| 3 | +#[derive(Debug, Clone, Copy, PartialEq, Eq)] | |
| 4 | +pub enum HealthStatus { | |
| 5 | + Starting, | |
| 6 | + Healthy, | |
| 7 | + Degraded, | |
| 8 | + Stopping, | |
| 9 | +} | |
| 10 | + | |
| 11 | +#[derive(Debug, Clone)] | |
| 12 | +pub enum ControlRequest { | |
| 13 | + Status, | |
| 14 | +} | |
| 15 | + | |
| 16 | +#[derive(Debug, Clone)] | |
| 17 | +pub struct StatusResponse { | |
| 18 | + pub protocol_version: u16, | |
| 19 | + pub health: HealthStatus, | |
| 20 | + pub in_flight_requests: usize, | |
| 21 | +} | |
| 22 | + | |
| 23 | +impl StatusResponse { | |
| 24 | + #[must_use] | |
| 25 | + pub fn healthy() -> Self { | |
| 26 | + Self { | |
| 27 | + protocol_version: PROTOCOL_VERSION, | |
| 28 | + health: HealthStatus::Healthy, | |
| 29 | + in_flight_requests: 0, | |
| 30 | + } | |
| 31 | + } | |
| 32 | +} | |
| 33 | + | |
| 34 | +#[cfg(test)] | |
| 35 | +mod tests { | |
| 36 | + use super::{HealthStatus, PROTOCOL_VERSION, StatusResponse}; | |
| 37 | + | |
| 38 | + #[test] | |
| 39 | + fn healthy_response_uses_protocol_version() { | |
| 40 | + let response = StatusResponse::healthy(); | |
| 41 | + assert_eq!(response.protocol_version, PROTOCOL_VERSION); | |
| 42 | + assert_eq!(response.health, HealthStatus::Healthy); | |
| 43 | + assert_eq!(response.in_flight_requests, 0); | |
| 44 | + } | |
| 45 | +} | |
garwarp/Cargo.tomladded@@ -0,0 +1,7 @@ | ||
| 1 | +[package] | |
| 2 | +name = "garwarp" | |
| 3 | +version = "0.1.0" | |
| 4 | +edition = "2024" | |
| 5 | + | |
| 6 | +[dependencies] | |
| 7 | +garwarp-ipc = { path = "../garwarp-ipc" } | |
garwarp/src/main.rsadded@@ -0,0 +1,5 @@ | ||
| 1 | +use garwarp_ipc::PROTOCOL_VERSION; | |
| 2 | + | |
| 3 | +fn main() { | |
| 4 | + println!("garwarp protocol v{PROTOCOL_VERSION}"); | |
| 5 | +} | |
garwarpctl/Cargo.tomladded@@ -0,0 +1,7 @@ | ||
| 1 | +[package] | |
| 2 | +name = "garwarpctl" | |
| 3 | +version = "0.1.0" | |
| 4 | +edition = "2024" | |
| 5 | + | |
| 6 | +[dependencies] | |
| 7 | +garwarp-ipc = { path = "../garwarp-ipc" } | |
garwarpctl/src/main.rsadded@@ -0,0 +1,5 @@ | ||
| 1 | +use garwarp_ipc::PROTOCOL_VERSION; | |
| 2 | + | |
| 3 | +fn main() { | |
| 4 | + println!("garwarpctl protocol v{PROTOCOL_VERSION}"); | |
| 5 | +} | |