Hansie Odendaal c80c3fd2e3
chore: config and naming updates (#27)
* Update config and crate naming

- Updated configs to the lates main repo configs.
- Updated all main repo crate namings to be same as the main repo.
- Added `create_dir_all` to `pub(crate) fn create_tempdir(custom_work_dir: Option<PathBuf>) -> std::io::Result<TempDir> {`.
- Wired in optional `persist_dir` when using the local deployer.
- Update `time` vulnerability

**Note:** Unsure about the `service_params` mapping in `pub(crate) fn cryptarchia_deployment(config: &GeneralConfig) -> CryptarchiaDeploymentSettings {`
2026-02-09 10:28:15 +02:00

94 lines
2.5 KiB
Rust

use std::{path::PathBuf, sync::Arc};
use reqwest::Url;
use super::DynError;
use crate::{nodes::ApiClient, topology::config::NodeConfigPatch};
/// Marker type used by scenario builders to request node control support.
#[derive(Clone, Copy, Debug, Default)]
pub struct NodeControlCapability;
/// Optional observability settings attached to a scenario.
#[derive(Clone, Debug, Default)]
pub struct ObservabilityCapability {
/// 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>,
/// Optional Grafana base URL for printing/logging (human access).
pub grafana_url: Option<Url>,
}
/// 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>),
}
/// Options for dynamically starting a node.
#[derive(Clone)]
pub struct StartNodeOptions {
/// How to select initial peers on startup.
pub peers: PeerSelection,
/// Optional node config patch applied before spawn.
pub config_patch: Option<NodeConfigPatch>,
/// Optional directory to persist node's tempdir to on stop.
pub persist_dir: Option<PathBuf>,
}
impl Default for StartNodeOptions {
fn default() -> Self {
Self {
peers: PeerSelection::DefaultLayout,
config_patch: None,
persist_dir: None,
}
}
}
impl StartNodeOptions {
pub fn create_patch<F>(mut self, f: F) -> Self
where
F: Fn(lb_node::config::RunConfig) -> Result<lb_node::config::RunConfig, DynError>
+ Send
+ Sync
+ 'static,
{
self.config_patch = Some(Arc::new(f));
self
}
}
/// 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;
}
impl RequiresNodeControl for ObservabilityCapability {
const REQUIRED: bool = false;
}
#[derive(Clone)]
pub struct StartedNode {
pub name: String,
pub api: ApiClient,
}