Skip to content

Commit

Permalink
refactor(storage-manager): remove unneeded structure StoreIntercept
Browse files Browse the repository at this point in the history
This structure was only created once to instantly be "split".

* plugins/zenoh-plugin-storage-manager/src/storages_mgt/mod.rs:
  - removed the unused `Capability` import,
  - removed the structure `StoreIntercept`,
* plugins/zenoh-plugin-storage-manager/src/storages_mgt/service.rs:
  - removed the `StoreIntercept` import,
  - changed the signature of the `start` method to take the `storage`
    and the `capability` as argument instead of the `StoreIntercept`.

Signed-off-by: Julien Loudet <[email protected]>
  • Loading branch information
J-Loudet committed Sep 16, 2024
1 parent e5c452e commit fc5a73a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 15 deletions.
13 changes: 2 additions & 11 deletions plugins/zenoh-plugin-storage-manager/src/storages_mgt/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ use std::sync::Arc;

use flume::Sender;
use zenoh::{session::Session, Result as ZResult};
use zenoh_backend_traits::{config::StorageConfig, Capability, VolumeInstance};
use zenoh_backend_traits::{config::StorageConfig, VolumeInstance};

mod service;
use service::StorageService;
Expand All @@ -26,11 +26,6 @@ pub enum StorageMessage {
GetStatus(tokio::sync::mpsc::Sender<serde_json::Value>),
}

pub struct StoreIntercept {
pub storage: Box<dyn zenoh_backend_traits::Storage>,
pub capability: Capability,
}

pub(crate) async fn create_and_start_storage(
admin_key: String,
config: StorageConfig,
Expand All @@ -40,10 +35,6 @@ pub(crate) async fn create_and_start_storage(
tracing::trace!("Create storage '{}'", &admin_key);
let capability = backend.get_capability();
let storage = backend.create_storage(config.clone()).await?;
let store_intercept = StoreIntercept {
storage,
capability,
};

// Ex: @/390CEC11A1E34977A1C609A35BC015E6/router/status/plugins/storage_manager/storages/demo1
// -> 390CEC11A1E34977A1C609A35BC015E6/demo1 (/<type> needed????)
Expand All @@ -57,7 +48,7 @@ pub(crate) async fn create_and_start_storage(
let (tx, rx) = flume::bounded(1);

tokio::task::spawn(async move {
StorageService::start(zenoh.clone(), config, &name, store_intercept, rx).await;
StorageService::start(zenoh.clone(), config, &name, storage, capability, rx).await;
});

Ok(tx)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ use zenoh_backend_traits::{
Capability, History, Persistence, StorageInsertionResult, StoredData,
};

use crate::storages_mgt::{StorageMessage, StoreIntercept};
use crate::storages_mgt::StorageMessage;

pub const WILDCARD_UPDATES_FILENAME: &str = "wildcard_updates";
pub const TOMBSTONE_FILENAME: &str = "tombstones";
Expand Down Expand Up @@ -72,7 +72,8 @@ impl StorageService {
session: Arc<Session>,
config: StorageConfig,
name: &str,
store_intercept: StoreIntercept,
storage: Box<dyn zenoh_backend_traits::Storage>,
capability: Capability,
rx: Receiver<StorageMessage>,
) {
// @TODO: optimization: if read_cost is high for the storage, initialize a cache for the
Expand All @@ -83,8 +84,8 @@ impl StorageService {
complete: config.complete,
name: name.to_string(),
strip_prefix: config.strip_prefix,
storage: Mutex::new(store_intercept.storage),
capability: store_intercept.capability,
storage: Mutex::new(storage),
capability,
tombstones: Arc::new(RwLock::new(KeBoxTree::default())),
wildcard_updates: Arc::new(RwLock::new(KeBoxTree::default())),
latest_updates: Arc::new(Mutex::new(HashMap::new())),
Expand Down

0 comments on commit fc5a73a

Please sign in to comment.