mirror of
https://github.com/logos-blockchain/logos-blockchain-testing.git
synced 2026-03-31 08:13:48 +00:00
Make source orchestration plan opaque
This commit is contained in:
parent
da2f51d46f
commit
7e0cdb54f8
@ -11,7 +11,7 @@ use super::{
|
||||
expectation::Expectation,
|
||||
runtime::{
|
||||
context::RunMetrics,
|
||||
orchestration::{SourceModeName, SourceOrchestrationPlan, SourceOrchestrationPlanError},
|
||||
orchestration::{SourceOrchestrationPlan, SourceOrchestrationPlanError},
|
||||
},
|
||||
workload::Workload,
|
||||
};
|
||||
@ -724,19 +724,11 @@ fn build_source_orchestration_plan(
|
||||
fn source_plan_error_to_build_error(error: SourceOrchestrationPlanError) -> ScenarioBuildError {
|
||||
match error {
|
||||
SourceOrchestrationPlanError::SourceModeNotWiredYet { mode } => {
|
||||
ScenarioBuildError::SourceModeNotWiredYet {
|
||||
mode: source_mode_name(mode),
|
||||
}
|
||||
ScenarioBuildError::SourceModeNotWiredYet { mode }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const fn source_mode_name(mode: SourceModeName) -> &'static str {
|
||||
match mode {
|
||||
SourceModeName::Attached => "Attached",
|
||||
}
|
||||
}
|
||||
|
||||
impl<E: Application> Builder<E, ()> {
|
||||
#[must_use]
|
||||
pub fn enable_node_control(self) -> Builder<E, NodeControlCapability> {
|
||||
|
||||
@ -3,9 +3,9 @@ mod source_orchestration_plan;
|
||||
#[allow(dead_code)]
|
||||
mod source_resolver;
|
||||
|
||||
pub(crate) use source_orchestration_plan::SourceOrchestrationMode;
|
||||
pub use source_orchestration_plan::{
|
||||
ManagedSource, SourceModeName, SourceOrchestrationMode, SourceOrchestrationPlan,
|
||||
SourceOrchestrationPlanError,
|
||||
ManagedSource, SourceOrchestrationPlan, SourceOrchestrationPlanError,
|
||||
};
|
||||
pub use source_resolver::{
|
||||
build_source_orchestration_plan, orchestrate_sources, orchestrate_sources_with_providers,
|
||||
|
||||
@ -1,5 +1,3 @@
|
||||
use std::fmt;
|
||||
|
||||
use crate::scenario::{AttachSource, ExternalNodeSource, ScenarioSources, SourceReadinessPolicy};
|
||||
|
||||
/// Explicit descriptor for managed node sourcing.
|
||||
@ -15,7 +13,7 @@ pub enum ManagedSource {
|
||||
/// This is scaffolding-only and is intentionally not executed by deployers
|
||||
/// yet.
|
||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||
pub enum SourceOrchestrationMode {
|
||||
pub(crate) enum SourceOrchestrationMode {
|
||||
Managed {
|
||||
managed: ManagedSource,
|
||||
external: Vec<ExternalNodeSource>,
|
||||
@ -34,28 +32,15 @@ pub enum SourceOrchestrationMode {
|
||||
/// This captures only mapping-time source intent and readiness policy.
|
||||
#[derive(Clone, Debug, Eq, PartialEq)]
|
||||
pub struct SourceOrchestrationPlan {
|
||||
pub mode: SourceOrchestrationMode,
|
||||
pub readiness_policy: SourceReadinessPolicy,
|
||||
}
|
||||
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||||
pub enum SourceModeName {
|
||||
Attached,
|
||||
}
|
||||
|
||||
impl fmt::Display for SourceModeName {
|
||||
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
|
||||
match self {
|
||||
Self::Attached => f.write_str("Attached"),
|
||||
}
|
||||
}
|
||||
mode: SourceOrchestrationMode,
|
||||
readiness_policy: SourceReadinessPolicy,
|
||||
}
|
||||
|
||||
/// Validation failure while building orchestration plan from sources.
|
||||
#[derive(Debug, thiserror::Error)]
|
||||
pub enum SourceOrchestrationPlanError {
|
||||
#[error("source mode '{mode}' is not wired into deployers yet")]
|
||||
SourceModeNotWiredYet { mode: SourceModeName },
|
||||
SourceModeNotWiredYet { mode: &'static str },
|
||||
}
|
||||
|
||||
impl SourceOrchestrationPlan {
|
||||
@ -71,6 +56,11 @@ impl SourceOrchestrationPlan {
|
||||
})
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub(crate) fn mode(&self) -> &SourceOrchestrationMode {
|
||||
&self.mode
|
||||
}
|
||||
|
||||
#[must_use]
|
||||
pub fn external_sources(&self) -> &[ExternalNodeSource] {
|
||||
match &self.mode {
|
||||
@ -94,7 +84,7 @@ mod tests {
|
||||
.expect("attached sources should build a source orchestration plan");
|
||||
|
||||
assert!(matches!(
|
||||
plan.mode,
|
||||
plan.mode(),
|
||||
SourceOrchestrationMode::Attached { .. }
|
||||
));
|
||||
}
|
||||
|
||||
@ -52,7 +52,7 @@ pub async fn resolve_sources<E: Application>(
|
||||
plan: &SourceOrchestrationPlan,
|
||||
providers: &SourceProviders<E>,
|
||||
) -> Result<ResolvedSources<E>, SourceResolveError> {
|
||||
match &plan.mode {
|
||||
match plan.mode() {
|
||||
SourceOrchestrationMode::Managed { managed, .. } => {
|
||||
let managed_nodes = providers.managed.provide(managed).await?;
|
||||
let external_nodes = providers.external.provide(plan.external_sources()).await?;
|
||||
@ -115,7 +115,8 @@ pub async fn orchestrate_sources_with_providers<E: Application>(
|
||||
) -> Result<NodeClients<E>, DynError> {
|
||||
let resolved = resolve_sources(plan, &providers).await?;
|
||||
|
||||
if matches!(plan.mode, SourceOrchestrationMode::Managed { .. }) && resolved.managed.is_empty() {
|
||||
if matches!(plan.mode(), SourceOrchestrationMode::Managed { .. }) && resolved.managed.is_empty()
|
||||
{
|
||||
return Err(SourceResolveError::ManagedNodesMissing.into());
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user