diff --git a/plugins/zenoh-plugin-storage-manager/tests/operations.rs b/plugins/zenoh-plugin-storage-manager/tests/operations.rs index a4293f31f1..cb1c42c201 100644 --- a/plugins/zenoh-plugin-storage-manager/tests/operations.rs +++ b/plugins/zenoh-plugin-storage-manager/tests/operations.rs @@ -78,7 +78,10 @@ async fn test_updates_in_order() { ) .unwrap(); - let runtime = zenoh::runtime::Runtime::new(config).await.unwrap(); + let runtime = zenoh::runtime::RuntimeBuilder::new(config) + .build() + .await + .unwrap(); let storage = zenoh_plugin_storage_manager::StoragesPlugin::start("storage-manager", &runtime).unwrap(); diff --git a/plugins/zenoh-plugin-storage-manager/tests/wildcard.rs b/plugins/zenoh-plugin-storage-manager/tests/wildcard.rs index 60970b2247..75fb6d3a87 100644 --- a/plugins/zenoh-plugin-storage-manager/tests/wildcard.rs +++ b/plugins/zenoh-plugin-storage-manager/tests/wildcard.rs @@ -79,7 +79,10 @@ async fn test_wild_card_in_order() { ) .unwrap(); - let runtime = zenoh::runtime::Runtime::new(config).await.unwrap(); + let runtime = zenoh::runtime::RuntimeBuilder::new(config) + .build() + .await + .unwrap(); let storage = zenoh_plugin_storage_manager::StoragesPlugin::start("storage-manager", &runtime).unwrap(); diff --git a/zenoh/src/net/runtime/mod.rs b/zenoh/src/net/runtime/mod.rs index 765eab91bb..364891460a 100644 --- a/zenoh/src/net/runtime/mod.rs +++ b/zenoh/src/net/runtime/mod.rs @@ -153,6 +153,11 @@ impl RuntimeBuilder { *handler.runtime.write().unwrap() = Runtime::downgrade(&runtime); get_mut_unchecked(&mut runtime.state.router.clone()).init_link_state(runtime.clone()); + // Admin space + if start_admin_space { + AdminSpace::start(&runtime, LONG_VERSION.clone()).await; + } + // Start plugins #[cfg(all(feature = "unstable", feature = "plugins"))] crate::plugins::loader::start_plugins(&runtime); @@ -184,11 +189,6 @@ impl RuntimeBuilder { } }); - // Admin space - if start_admin_space { - AdminSpace::start(&runtime, LONG_VERSION.clone()).await; - } - Ok(runtime) } } @@ -210,19 +210,6 @@ impl StructVersion for Runtime { impl PluginStartArgs for Runtime {} impl Runtime { - pub async fn new(config: Config) -> ZResult { - // Create plugin_manager and load plugins - let mut runtime = Runtime::init(config).await?; - match runtime.start().await { - Ok(()) => Ok(runtime), - Err(err) => Err(err), - } - } - - pub(crate) async fn init(config: Config) -> ZResult { - RuntimeBuilder::new(config).build().await - } - #[inline(always)] pub(crate) fn manager(&self) -> &TransportManager { &self.state.manager diff --git a/zenoh/src/net/runtime/orchestrator.rs b/zenoh/src/net/runtime/orchestrator.rs index 687fa90649..c2c7ecedd2 100644 --- a/zenoh/src/net/runtime/orchestrator.rs +++ b/zenoh/src/net/runtime/orchestrator.rs @@ -43,7 +43,7 @@ pub enum Loop { } impl Runtime { - pub(crate) async fn start(&mut self) -> ZResult<()> { + pub async fn start(&mut self) -> ZResult<()> { match self.whatami() { WhatAmI::Client => self.start_client().await, WhatAmI::Peer => self.start_peer().await, diff --git a/zenoh/src/session.rs b/zenoh/src/session.rs index 37ae02fe8b..eaca07d964 100644 --- a/zenoh/src/session.rs +++ b/zenoh/src/session.rs @@ -28,6 +28,7 @@ use crate::prelude::{KeyExpr, Parameters}; use crate::publication::*; use crate::query::*; use crate::queryable::*; +use crate::runtime::RuntimeBuilder; #[cfg(feature = "unstable")] use crate::sample::Attachment; use crate::sample::DataInfo; @@ -824,7 +825,7 @@ impl Session { tracing::debug!("Config: {:?}", &config); let aggregated_subscribers = config.aggregation().subscribers().clone(); let aggregated_publishers = config.aggregation().publishers().clone(); - let mut runtime = Runtime::init(config).await?; + let mut runtime = RuntimeBuilder::new(config).build().await?; let mut session = Self::init( runtime.clone(), diff --git a/zenoh/tests/session.rs b/zenoh/tests/session.rs index 1c18a16c50..a84b4bd654 100644 --- a/zenoh/tests/session.rs +++ b/zenoh/tests/session.rs @@ -15,7 +15,7 @@ use std::sync::atomic::{AtomicUsize, Ordering}; use std::sync::Arc; use std::time::Duration; use zenoh::prelude::r#async::*; -use zenoh::runtime::Runtime; +use zenoh::runtime::{Runtime, RuntimeBuilder}; use zenoh_core::ztimeout; const TIMEOUT: Duration = Duration::from_secs(60); @@ -209,7 +209,7 @@ async fn open_session_unicast_runtime(endpoints: &[&str]) -> (Runtime, Runtime) .collect::>(); config.scouting.multicast.set_enabled(Some(false)).unwrap(); println!("[ ][01a] Creating r1 session runtime: {:?}", endpoints); - let r1 = Runtime::new(config).await.unwrap(); + let r1 = RuntimeBuilder::new(config).build().await.unwrap(); let mut config = config::peer(); config.connect.endpoints = endpoints @@ -218,7 +218,7 @@ async fn open_session_unicast_runtime(endpoints: &[&str]) -> (Runtime, Runtime) .collect::>(); config.scouting.multicast.set_enabled(Some(false)).unwrap(); println!("[ ][02a] Creating r2 session runtime: {:?}", endpoints); - let r2 = Runtime::new(config).await.unwrap(); + let r2 = RuntimeBuilder::new(config).build().await.unwrap(); (r1, r2) }