2025-12-01 12:48:39 +01:00
|
|
|
use async_trait::async_trait;
|
2025-12-16 21:20:27 +01:00
|
|
|
use reqwest::Url;
|
2025-12-01 12:48:39 +01:00
|
|
|
|
|
|
|
|
use super::DynError;
|
2026-01-14 12:44:31 +01:00
|
|
|
use crate::{nodes::ApiClient, topology::generation::NodeRole};
|
2025-12-01 12:48:39 +01:00
|
|
|
|
|
|
|
|
/// Marker type used by scenario builders to request node control support.
|
|
|
|
|
#[derive(Clone, Copy, Debug, Default)]
|
|
|
|
|
pub struct NodeControlCapability;
|
|
|
|
|
|
2025-12-16 21:20:27 +01:00
|
|
|
/// Optional observability settings attached to a scenario.
|
|
|
|
|
#[derive(Clone, Debug, Default)]
|
|
|
|
|
pub struct ObservabilityCapability {
|
2025-12-17 17:04:41 +01:00
|
|
|
/// Prometheus-compatible base URL used by the *runner process* to query
|
|
|
|
|
/// metrics (commonly a localhost port-forward, but can be any reachable
|
|
|
|
|
/// endpoint).
|
|
|
|
|
pub metrics_query_url: Option<Url>,
|
|
|
|
|
/// Full OTLP HTTP metrics ingest endpoint used by *nodes* to export metrics
|
|
|
|
|
/// (backend-specific host and path).
|
|
|
|
|
pub metrics_otlp_ingest_url: Option<Url>,
|
2025-12-17 18:28:36 +01:00
|
|
|
/// Optional Grafana base URL for printing/logging (human access).
|
|
|
|
|
pub grafana_url: Option<Url>,
|
2025-12-16 21:20:27 +01:00
|
|
|
}
|
|
|
|
|
|
2026-01-15 04:34:06 +01:00
|
|
|
/// Options for dynamically starting a node.
|
|
|
|
|
#[derive(Clone, Debug, Default)]
|
|
|
|
|
pub struct StartNodeOptions {
|
|
|
|
|
/// Names of nodes to connect to on startup (implementation-defined).
|
|
|
|
|
pub peer_names: Vec<String>,
|
|
|
|
|
}
|
|
|
|
|
|
2025-12-01 12:48:39 +01:00
|
|
|
/// Trait implemented by scenario capability markers to signal whether node
|
|
|
|
|
/// control is required.
|
|
|
|
|
pub trait RequiresNodeControl {
|
|
|
|
|
const REQUIRED: bool;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl RequiresNodeControl for () {
|
|
|
|
|
const REQUIRED: bool = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl RequiresNodeControl for NodeControlCapability {
|
|
|
|
|
const REQUIRED: bool = true;
|
|
|
|
|
}
|
|
|
|
|
|
2025-12-16 21:20:27 +01:00
|
|
|
impl RequiresNodeControl for ObservabilityCapability {
|
|
|
|
|
const REQUIRED: bool = false;
|
|
|
|
|
}
|
|
|
|
|
|
2025-12-01 12:48:39 +01:00
|
|
|
/// Interface exposed by runners that can restart nodes at runtime.
|
|
|
|
|
#[async_trait]
|
|
|
|
|
pub trait NodeControlHandle: Send + Sync {
|
|
|
|
|
async fn restart_validator(&self, index: usize) -> Result<(), DynError>;
|
2025-12-09 06:30:18 +01:00
|
|
|
|
2025-12-01 12:48:39 +01:00
|
|
|
async fn restart_executor(&self, index: usize) -> Result<(), DynError>;
|
2026-01-14 12:44:31 +01:00
|
|
|
|
|
|
|
|
async fn start_validator(&self, _name: &str) -> Result<StartedNode, DynError> {
|
|
|
|
|
Err("start_validator not supported by this deployer".into())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async fn start_executor(&self, _name: &str) -> Result<StartedNode, DynError> {
|
|
|
|
|
Err("start_executor not supported by this deployer".into())
|
|
|
|
|
}
|
2026-01-15 04:34:06 +01:00
|
|
|
|
|
|
|
|
async fn start_validator_with(
|
|
|
|
|
&self,
|
|
|
|
|
_name: &str,
|
|
|
|
|
_options: StartNodeOptions,
|
|
|
|
|
) -> Result<StartedNode, DynError> {
|
|
|
|
|
Err("start_validator_with not supported by this deployer".into())
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
async fn start_executor_with(
|
|
|
|
|
&self,
|
|
|
|
|
_name: &str,
|
|
|
|
|
_options: StartNodeOptions,
|
|
|
|
|
) -> Result<StartedNode, DynError> {
|
|
|
|
|
Err("start_executor_with not supported by this deployer".into())
|
|
|
|
|
}
|
2026-01-14 12:44:31 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#[derive(Clone)]
|
|
|
|
|
pub struct StartedNode {
|
|
|
|
|
pub name: String,
|
|
|
|
|
pub role: NodeRole,
|
|
|
|
|
pub api: ApiClient,
|
2025-12-01 12:48:39 +01:00
|
|
|
}
|