diff --git a/CHANGELOG.md b/CHANGELOG.md index cce8216..8380c9c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,12 +2,22 @@ All notable changes to this project will be documented in this file. +## [0.11.5] - 2025-04-03 + +### 🐛 Bug Fixes + +- Mapping store name with db url + ## [0.11.4] - 2025-04-02 ### 🚜 Refactor - Updating wasmtime to 31.0.0 +### ⚙️ Miscellaneous Tasks + +- Release + ## [0.11.3] - 2025-04-02 ### 🐛 Bug Fixes diff --git a/Cargo.lock b/Cargo.lock index 4ea8881..33373e7 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -781,7 +781,7 @@ dependencies = [ [[package]] name = "dictionary" -version = "0.11.4" +version = "0.11.5" dependencies = [ "async-trait", "reactor", @@ -955,7 +955,7 @@ dependencies = [ [[package]] name = "fastedge-run" -version = "0.11.4" +version = "0.11.5" dependencies = [ "anyhow", "async-trait", @@ -1528,7 +1528,7 @@ dependencies = [ [[package]] name = "http-backend" -version = "0.11.4" +version = "0.11.5" dependencies = [ "anyhow", "claims", @@ -1571,7 +1571,7 @@ dependencies = [ [[package]] name = "http-service" -version = "0.11.4" +version = "0.11.5" dependencies = [ "anyhow", "async-trait", @@ -1962,7 +1962,7 @@ dependencies = [ [[package]] name = "key-value-store" -version = "0.11.4" +version = "0.11.5" dependencies = [ "async-trait", "reactor", @@ -2801,7 +2801,7 @@ dependencies = [ [[package]] name = "reactor" -version = "0.11.4" +version = "0.11.5" dependencies = [ "wasmtime", ] @@ -2912,7 +2912,7 @@ dependencies = [ [[package]] name = "runtime" -version = "0.11.4" +version = "0.11.5" dependencies = [ "anyhow", "async-trait", @@ -3093,7 +3093,7 @@ dependencies = [ [[package]] name = "secret" -version = "0.11.4" +version = "0.11.5" dependencies = [ "anyhow", "reactor", diff --git a/Cargo.toml b/Cargo.toml index 54e3c10..81dc1ea 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,7 +3,7 @@ members = ["crates/*"] resolver = "2" [workspace.package] -version = "0.11.4" +version = "0.11.5" edition = "2021" publish = false authors = ["FastEdge Development Team"] diff --git a/crates/key-value-store/src/lib.rs b/crates/key-value-store/src/lib.rs index 8e5896b..56372aa 100644 --- a/crates/key-value-store/src/lib.rs +++ b/crates/key-value-store/src/lib.rs @@ -1,7 +1,7 @@ use reactor::gcore::fastedge::key_value; use slab::Slab; use smol_str::SmolStr; -use std::collections::HashSet; +use std::collections::HashMap; use std::sync::Arc; use wasmtime::component::Resource; @@ -18,12 +18,13 @@ pub trait Store: Sync + Send { #[async_trait::async_trait] pub trait StoreManager: Sync + Send { - async fn get_store(&self, name: &str) -> Result, Error>; + /// Get a store by db url. + async fn get_store(&self, param: &str) -> Result, Error>; } #[derive(Clone)] pub struct KeyValueStore { - allowed_stores: HashSet, + allowed_stores: HashMap, manager: Arc, stores: Slab>, } @@ -73,7 +74,7 @@ impl key_value::HostStore for KeyValueStore { impl key_value::Host for KeyValueStore {} impl KeyValueStore { - pub fn new(allowed_stores: Vec, manager: Arc) -> Self { + pub fn new(allowed_stores: Vec<(SmolStr, SmolStr)>, manager: Arc) -> Self { Self { allowed_stores: allowed_stores.into_iter().collect(), manager, @@ -83,8 +84,8 @@ impl KeyValueStore { /// Open a store by name. Return the store ID. pub async fn open(&mut self, name: &str) -> Result { - if self.allowed_stores.contains(name) { - let store = self.manager.get_store(name).await?; + if let Some(param) = self.allowed_stores.get(name) { + let store = self.manager.get_store(¶m).await?; Ok(self.stores.insert(store) as u32) } else { Err(Error::AccessDenied) diff --git a/src/context.rs b/src/context.rs index 5dca5f6..c919f1a 100644 --- a/src/context.rs +++ b/src/context.rs @@ -74,7 +74,7 @@ impl ContextT for Context { } fn make_key_value_store(&self, stores: &Vec) -> KeyValueStore { - let stores = stores.iter().map(|s| s.name.clone()).collect(); + let stores = stores.iter().map(|s| (s.name.clone(), s.param.clone())).collect(); KeyValueStore::new(stores, Arc::new(CliStoreManager)) } }