2026-02-05 08:23:14 +02:00
|
|
|
use std::sync::Arc;
|
|
|
|
|
|
2025-12-16 21:20:27 +01:00
|
|
|
use reqwest::Url;
|
2025-12-01 12:48:39 +01:00
|
|
|
|
|
|
|
|
use super::DynError;
|
2026-02-05 08:23:14 +02:00
|
|
|
use crate::{nodes::ApiClient, topology::config::NodeConfigPatch};
|
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-19 08:34:17 +01:00
|
|
|
/// Peer selection strategy for dynamically started nodes.
|
|
|
|
|
#[derive(Clone, Debug)]
|
|
|
|
|
pub enum PeerSelection {
|
|
|
|
|
/// Use the topology default (star/chain/full).
|
|
|
|
|
DefaultLayout,
|
|
|
|
|
/// Start without any initial peers.
|
|
|
|
|
None,
|
|
|
|
|
/// Connect to the named peers.
|
|
|
|
|
Named(Vec<String>),
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-15 04:34:06 +01:00
|
|
|
/// Options for dynamically starting a node.
|
2026-02-05 08:23:14 +02:00
|
|
|
#[derive(Clone)]
|
2026-01-15 04:34:06 +01:00
|
|
|
pub struct StartNodeOptions {
|
2026-01-19 08:34:17 +01:00
|
|
|
/// How to select initial peers on startup.
|
|
|
|
|
pub peers: PeerSelection,
|
2026-02-05 08:23:14 +02:00
|
|
|
/// Optional node config patch applied before spawn.
|
|
|
|
|
pub config_patch: Option<NodeConfigPatch>,
|
2026-01-19 08:34:17 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
impl Default for StartNodeOptions {
|
|
|
|
|
fn default() -> Self {
|
|
|
|
|
Self {
|
|
|
|
|
peers: PeerSelection::DefaultLayout,
|
2026-02-05 08:23:14 +02:00
|
|
|
config_patch: None,
|
2026-01-19 08:34:17 +01:00
|
|
|
}
|
|
|
|
|
}
|
2026-01-15 04:34:06 +01:00
|
|
|
}
|
|
|
|
|
|
2026-02-05 08:23:14 +02:00
|
|
|
impl StartNodeOptions {
|
|
|
|
|
pub fn create_patch<F>(mut self, f: F) -> Self
|
|
|
|
|
where
|
|
|
|
|
F: Fn(nomos_node::config::RunConfig) -> Result<nomos_node::config::RunConfig, DynError>
|
|
|
|
|
+ Send
|
|
|
|
|
+ Sync
|
|
|
|
|
+ 'static,
|
|
|
|
|
{
|
|
|
|
|
self.config_patch = Some(Arc::new(f));
|
|
|
|
|
self
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
2026-01-14 12:44:31 +01:00
|
|
|
#[derive(Clone)]
|
|
|
|
|
pub struct StartedNode {
|
|
|
|
|
pub name: String,
|
|
|
|
|
pub api: ApiClient,
|
2025-12-01 12:48:39 +01:00
|
|
|
}
|