Skip to content

Commit

Permalink
Bridge: fix static loading of plugins (#222)
Browse files Browse the repository at this point in the history
  • Loading branch information
JEnoch authored Apr 25, 2024
1 parent 8071514 commit 2e21a87
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
32 changes: 30 additions & 2 deletions zenoh-bridge-dds/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ use clap::{App, Arg};
use std::str::FromStr;
use std::time::{Duration, SystemTime};
use zenoh::config::{Config, ModeDependentValue};
use zenoh::plugins::PluginsManager;
use zenoh::prelude::r#async::*;
use zenoh::runtime::RuntimeBuilder;
use zenoh_plugin_dds::DDSPlugin;
use zenoh_plugin_trait::Plugin;

Expand Down Expand Up @@ -243,13 +245,39 @@ async fn main() {
tracing::info!("zenoh-bridge-dds {}", DDSPlugin::PLUGIN_LONG_VERSION);

let (config, watchdog_period) = parse_args();
tracing::info!("Zenoh {config:?}");

if let Some(period) = watchdog_period {
run_watchdog(period);
}

// Open a zenoh sessions. Plugins are automatically loaded by the open.
let _session = zenoh::open(config).res().await.unwrap();
let mut plugins_mgr = PluginsManager::static_plugins_only();

// declare REST plugin if specified in conf
if config.plugin("rest").is_some() {
plugins_mgr = plugins_mgr.declare_static_plugin::<zenoh_plugin_rest::RestPlugin>(true);
}

// declare DDS plugin
plugins_mgr = plugins_mgr.declare_static_plugin::<zenoh_plugin_dds::DDSPlugin>(true);

// create a zenoh Runtime.
let runtime = match RuntimeBuilder::new(config)
.plugins_manager(plugins_mgr)
.build()
.await
{
Ok(runtime) => runtime,
Err(e) => {
println!("{e}. Exiting...");
std::process::exit(-1);
}
};
// create a zenoh Session.
let _session = zenoh::init(runtime).res().await.unwrap_or_else(|e| {
println!("{e}. Exiting...");
std::process::exit(-1);
});

async_std::future::pending::<()>().await;
}
Expand Down
2 changes: 1 addition & 1 deletion zenoh-plugin-dds/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ impl Plugin for DDSPlugin {
type StartArgs = Runtime;
type Instance = RunningPlugin;

const DEFAULT_NAME: &'static str = "zenoh-plugin-dds";
const DEFAULT_NAME: &'static str = "dds";
const PLUGIN_VERSION: &'static str = plugin_version!();
const PLUGIN_LONG_VERSION: &'static str = plugin_long_version!();

Expand Down

0 comments on commit 2e21a87

Please sign in to comment.