Skip to content

Commit

Permalink
send + sync problem
Browse files Browse the repository at this point in the history
  • Loading branch information
milyin committed Nov 4, 2023
1 parent 13381dd commit 2c90716
Show file tree
Hide file tree
Showing 10 changed files with 248 additions and 257 deletions.
4 changes: 2 additions & 2 deletions plugins/example-plugin/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,13 +40,13 @@ const DEFAULT_SELECTOR: &str = "demo/example/**";
impl ZenohPlugin for ExamplePlugin {}
impl Plugin for ExamplePlugin {
type StartArgs = Runtime;
type RunningPlugin = zenoh::plugins::RunningPlugin;
type Instance = zenoh::plugins::RunningPlugin;

// A mandatory const to define, in case of the plugin is built as a standalone executable
const STATIC_NAME: &'static str = "example";

// The first operation called by zenohd on the plugin
fn start(name: &str, runtime: &Self::StartArgs) -> ZResult<Self::RunningPlugin> {
fn start(name: &str, runtime: &Self::StartArgs) -> ZResult<Self::Instance> {
let config = runtime.config().lock();
let self_cfg = config.plugin(name).unwrap().as_object().unwrap();
// get the plugin's config details from self_cfg Map (here the "storage-selector" property)
Expand Down
4 changes: 2 additions & 2 deletions plugins/example-storage-plugin/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,9 @@ zenoh_plugin_trait::declare_plugin!(ExampleBackend);

impl Plugin for ExampleBackend {
type StartArgs = VolumeConfig;
type RunningPlugin = VolumePlugin;
type Instance = VolumePlugin;

fn start(_name: &str, _args: &Self::StartArgs) -> ZResult<Self::RunningPlugin> {
fn start(_name: &str, _args: &Self::StartArgs) -> ZResult<Self::Instance> {
let volume = ExampleBackend {};
Ok(Box::new(volume))
}
Expand Down
2 changes: 1 addition & 1 deletion plugins/zenoh-plugin-rest/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ impl ZenohPlugin for RestPlugin {}

impl Plugin for RestPlugin {
type StartArgs = Runtime;
type RunningPlugin = zenoh::plugins::RunningPlugin;
type Instance = zenoh::plugins::RunningPlugin;
const STATIC_NAME: &'static str = "rest";

fn start(name: &str, runtime: &Self::StartArgs) -> ZResult<zenoh::plugins::RunningPlugin> {
Expand Down
14 changes: 7 additions & 7 deletions plugins/zenoh-plugin-storage-manager/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,9 @@ impl Plugin for StoragesPlugin {
const STATIC_NAME: &'static str = "storage_manager";

type StartArgs = Runtime;
type RunningPlugin = zenoh::plugins::RunningPlugin;
type Instance = zenoh::plugins::RunningPlugin;

fn start(name: &str, runtime: &Self::StartArgs) -> ZResult<Self::RunningPlugin> {
fn start(name: &str, runtime: &Self::StartArgs) -> ZResult<Self::Instance> {
std::mem::drop(env_logger::try_init());
log::debug!("StorageManager plugin {}", LONG_VERSION.as_str());
let config =
Expand Down Expand Up @@ -109,7 +109,7 @@ impl StorageRuntimeInner {
let session = Arc::new(zenoh::init(runtime.clone()).res_sync().unwrap());

let plugins_manager = PluginsManager::dynamic(lib_loader.clone(), BACKEND_LIB_PREFIX)
.add_static::<MemoryBackend>();
.add_static_plugin::<MemoryBackend>();

let mut new_self = StorageRuntimeInner {
name,
Expand Down Expand Up @@ -190,12 +190,12 @@ impl StorageRuntimeInner {
let volume_id = storage.volume_id.clone();
let backend = self.plugins_manager.running_plugin(&volume_id)?;
let storage_name = storage.name.clone();
let in_interceptor = backend.running().incoming_data_interceptor();
let out_interceptor = backend.running().outgoing_data_interceptor();
let in_interceptor = backend.instance().incoming_data_interceptor();
let out_interceptor = backend.instance().outgoing_data_interceptor();
let stopper = async_std::task::block_on(create_and_start_storage(
admin_key,
storage,
backend.running(),
backend.instance(),
in_interceptor,
out_interceptor,
self.session.clone(),
Expand Down Expand Up @@ -270,7 +270,7 @@ impl RunningPluginTrait for StorageRuntime {
{
responses.push(zenoh::plugins::Response::new(
key.clone(),
plugin.running().get_admin_status(),
plugin.instance().get_admin_status(),
))
}
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ pub struct MemoryBackend {

impl Plugin for MemoryBackend {
type StartArgs = VolumeConfig;
type RunningPlugin = VolumePlugin;
type Instance = VolumePlugin;

const STATIC_NAME: &'static str = MEMORY_BACKEND_NAME;

Expand Down
6 changes: 3 additions & 3 deletions plugins/zenoh-plugin-trait/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,14 +51,14 @@ pub trait CompatibilityVersion {

pub trait PluginControl {
fn plugins(&self) -> Vec<&str>;
fn status(&self, name: &str) -> PluginStatus;
// fn status(&self, name: &str) -> PluginStatus;
}

pub trait Plugin: Sized + 'static {
type StartArgs: CompatibilityVersion;
type RunningPlugin: CompatibilityVersion;
type Instance: CompatibilityVersion;
/// Your plugins' default name when statically linked.
const STATIC_NAME: &'static str;
/// Starts your plugin. Use `Ok` to return your plugin's control structure
fn start(name: &str, args: &Self::StartArgs) -> ZResult<Self::RunningPlugin>;
fn start(name: &str, args: &Self::StartArgs) -> ZResult<Self::Instance>;
}
Loading

0 comments on commit 2c90716

Please sign in to comment.