Skip to content

Commit

Permalink
no full failure due to one storage
Browse files Browse the repository at this point in the history
  • Loading branch information
milyin committed Dec 5, 2023
1 parent 4439ce3 commit 51d5eb3
Showing 1 changed file with 16 additions and 10 deletions.
26 changes: 16 additions & 10 deletions plugins/zenoh-plugin-storage-manager/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ use zenoh_backend_traits::config::VolumeConfig;
use zenoh_backend_traits::VolumePlugin;
use zenoh_core::zlock;
use zenoh_plugin_trait::Plugin;
use zenoh_plugin_trait::PluginConditionSetter;

Check warning on line 41 in plugins/zenoh-plugin-storage-manager/src/lib.rs

View workflow job for this annotation

GitHub Actions / Run tests on ubuntu-latest

unused import: `zenoh_plugin_trait::PluginConditionSetter`

Check warning on line 41 in plugins/zenoh-plugin-storage-manager/src/lib.rs

View workflow job for this annotation

GitHub Actions / Run tests on macOS-latest

unused import: `zenoh_plugin_trait::PluginConditionSetter`

Check warning on line 41 in plugins/zenoh-plugin-storage-manager/src/lib.rs

View workflow job for this annotation

GitHub Actions / Run tests on windows-latest

unused import: `zenoh_plugin_trait::PluginConditionSetter`

Check warning on line 41 in plugins/zenoh-plugin-storage-manager/src/lib.rs

View workflow job for this annotation

GitHub Actions / Run tests on ubuntu-latest

unused import: `zenoh_plugin_trait::PluginConditionSetter`

Check warning on line 41 in plugins/zenoh-plugin-storage-manager/src/lib.rs

View workflow job for this annotation

GitHub Actions / Run tests on macOS-latest

unused import: `zenoh_plugin_trait::PluginConditionSetter`

Check warning on line 41 in plugins/zenoh-plugin-storage-manager/src/lib.rs

View workflow job for this annotation

GitHub Actions / Run tests on windows-latest

unused import: `zenoh_plugin_trait::PluginConditionSetter`
use zenoh_plugin_trait::PluginControl;
use zenoh_plugin_trait::PluginReport;
use zenoh_plugin_trait::PluginStatusRec;
Expand Down Expand Up @@ -111,31 +112,36 @@ impl StorageRuntimeInner {
.map(|search_dirs| LibLoader::new(&search_dirs, false))
.unwrap_or_default();

let session = Arc::new(zenoh::init(runtime.clone()).res_sync().unwrap());

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


let session = Arc::new(zenoh::init(runtime.clone()).res_sync()?);

// After this moment result should be only Ok. Failure of loading of one voulme or storage should not affect others.

let mut new_self = StorageRuntimeInner {
name,
runtime,
session,
storages: Default::default(),
plugins_manager,
};
new_self.spawn_volume(VolumeConfig {
let _ = new_self.spawn_volume(VolumeConfig {
name: MEMORY_BACKEND_NAME.into(),
backend: None,
paths: None,
required: false,
rest: Default::default(),
})?;
new_self.update(
volumes
.into_iter()
.map(ConfigDiff::AddVolume)
.chain(storages.into_iter().map(ConfigDiff::AddStorage)),
)?;
});
for volume in volumes {
let _ = new_self
.spawn_volume(volume);
}
for storage in storages {
let _ = new_self
.spawn_storage(storage);
}
Ok(new_self)
}
fn update<I: IntoIterator<Item = ConfigDiff>>(&mut self, diffs: I) -> ZResult<()> {
Expand Down

0 comments on commit 51d5eb3

Please sign in to comment.