diff --git a/core/Cargo.lock b/core/Cargo.lock index 96b630981cb..deda3e10257 100644 --- a/core/Cargo.lock +++ b/core/Cargo.lock @@ -5398,7 +5398,7 @@ dependencies = [ "proc-macro2", "proc-macro2-diagnostics", "quote", - "syn 2.0.79", + "syn 2.0.81", ] [[package]] @@ -5949,7 +5949,7 @@ checksum = "af066a9c399a26e020ada66a034357a868728e72cd426f3adcd35f80d88d88c8" dependencies = [ "proc-macro2", "quote", - "syn 2.0.79", + "syn 2.0.81", "version_check", "yansi", ] diff --git a/core/src/raw/adapters/kv/api.rs b/core/src/raw/adapters/kv/api.rs index 8f9b8e96583..2790a53d923 100644 --- a/core/src/raw/adapters/kv/api.rs +++ b/core/src/raw/adapters/kv/api.rs @@ -96,8 +96,8 @@ pub trait Adapter: Send + Sync + Debug + Unpin + 'static { /// TODO: use default associate type `= ()` after stablized type Scanner: Scan; - /// Return the metadata of this key value accessor. - fn metadata(&self) -> Metadata; + /// Return the info of this key value accessor. + fn info(&self) -> Info; /// Get a key from service. /// @@ -196,14 +196,14 @@ pub trait Adapter: Send + Sync + Debug + Unpin + 'static { } } -/// Metadata for this key value accessor. -pub struct Metadata { +/// Info for this key value accessor. +pub struct Info { scheme: Scheme, name: String, capabilities: Capability, } -impl Metadata { +impl Info { /// Create a new KeyValueAccessorInfo. pub fn new(scheme: Scheme, name: &str, capabilities: Capability) -> Self { Self { @@ -228,14 +228,3 @@ impl Metadata { self.capabilities } } - -impl From for AccessorInfo { - fn from(m: Metadata) -> AccessorInfo { - let mut am = AccessorInfo::default(); - am.set_name(m.name()); - am.set_scheme(m.scheme()); - am.set_native_capability(m.capabilities()); - - am - } -} diff --git a/core/src/raw/adapters/kv/backend.rs b/core/src/raw/adapters/kv/backend.rs index 6b625c78b6e..a2f378a46bc 100644 --- a/core/src/raw/adapters/kv/backend.rs +++ b/core/src/raw/adapters/kv/backend.rs @@ -72,10 +72,13 @@ impl Access for Backend { type BlockingLister = HierarchyLister; fn info(&self) -> Arc { - let mut am: AccessorInfo = self.kv.metadata().into(); + let kv_info = self.kv.info(); + let mut am: AccessorInfo = AccessorInfo::default(); am.set_root(&self.root); + am.set_scheme(kv_info.scheme()); + am.set_name(kv_info.name()); - let mut cap = am.native_capability(); + let mut cap = kv_info.capabilities(); if cap.read { cap.stat = true; } diff --git a/core/src/raw/adapters/kv/mod.rs b/core/src/raw/adapters/kv/mod.rs index c03c8d71b80..71992516042 100644 --- a/core/src/raw/adapters/kv/mod.rs +++ b/core/src/raw/adapters/kv/mod.rs @@ -21,7 +21,7 @@ mod api; pub use api::Adapter; -pub use api::Metadata; +pub use api::Info; pub use api::Scan; #[cfg(any( feature = "services-cloudflare-kv", diff --git a/core/src/raw/adapters/typed_kv/api.rs b/core/src/raw/adapters/typed_kv/api.rs index 0fecb9d0129..f1e4a95fc47 100644 --- a/core/src/raw/adapters/typed_kv/api.rs +++ b/core/src/raw/adapters/typed_kv/api.rs @@ -45,7 +45,7 @@ use crate::Scheme; /// Ideally, we should use `typed_kv::Adapter` instead of `kv::Adapter` for /// in-memory rust libs like moka and dashmap. pub trait Adapter: Send + Sync + Debug + Unpin + 'static { - /// Get the scheme and name of current adapter. + /// Return the info of this key value accessor. fn info(&self) -> Info; /// Get a value from adapter. diff --git a/core/src/services/atomicserver/backend.rs b/core/src/services/atomicserver/backend.rs index 2a8318daa7a..546e6d25989 100644 --- a/core/src/services/atomicserver/backend.rs +++ b/core/src/services/atomicserver/backend.rs @@ -353,8 +353,8 @@ impl Adapter { impl kv::Adapter for Adapter { type Scanner = (); - fn metadata(&self) -> kv::Metadata { - kv::Metadata::new( + fn info(&self) -> kv::Info { + kv::Info::new( Scheme::Atomicserver, "atomicserver", Capability { diff --git a/core/src/services/cacache/backend.rs b/core/src/services/cacache/backend.rs index 2083f124cf5..1ef193a6825 100644 --- a/core/src/services/cacache/backend.rs +++ b/core/src/services/cacache/backend.rs @@ -87,8 +87,8 @@ impl Debug for Adapter { impl kv::Adapter for Adapter { type Scanner = (); - fn metadata(&self) -> kv::Metadata { - kv::Metadata::new( + fn info(&self) -> kv::Info { + kv::Info::new( Scheme::Cacache, &self.datadir, Capability { diff --git a/core/src/services/cloudflare_kv/backend.rs b/core/src/services/cloudflare_kv/backend.rs index ce68192f58e..c2be1ddd166 100644 --- a/core/src/services/cloudflare_kv/backend.rs +++ b/core/src/services/cloudflare_kv/backend.rs @@ -183,8 +183,8 @@ impl Adapter { impl kv::Adapter for Adapter { type Scanner = kv::Scanner; - fn metadata(&self) -> kv::Metadata { - kv::Metadata::new( + fn info(&self) -> kv::Info { + kv::Info::new( Scheme::CloudflareKv, &self.namespace_id, Capability { diff --git a/core/src/services/d1/backend.rs b/core/src/services/d1/backend.rs index b1c992b1a8c..643617431e4 100644 --- a/core/src/services/d1/backend.rs +++ b/core/src/services/d1/backend.rs @@ -260,8 +260,8 @@ impl Adapter { impl kv::Adapter for Adapter { type Scanner = (); - fn metadata(&self) -> kv::Metadata { - kv::Metadata::new( + fn info(&self) -> kv::Info { + kv::Info::new( Scheme::D1, &self.table, Capability { diff --git a/core/src/services/etcd/backend.rs b/core/src/services/etcd/backend.rs index d37fb35d2a8..4a6e94f13bd 100644 --- a/core/src/services/etcd/backend.rs +++ b/core/src/services/etcd/backend.rs @@ -274,8 +274,8 @@ impl Adapter { impl kv::Adapter for Adapter { type Scanner = kv::ScanStdIter>>; - fn metadata(&self) -> kv::Metadata { - kv::Metadata::new( + fn info(&self) -> kv::Info { + kv::Info::new( Scheme::Etcd, &self.endpoints.join(","), Capability { diff --git a/core/src/services/foundationdb/backend.rs b/core/src/services/foundationdb/backend.rs index d28b70152bc..b9c70946b5f 100644 --- a/core/src/services/foundationdb/backend.rs +++ b/core/src/services/foundationdb/backend.rs @@ -112,8 +112,8 @@ impl Debug for Adapter { impl kv::Adapter for Adapter { type Scanner = (); - fn metadata(&self) -> kv::Metadata { - kv::Metadata::new( + fn info(&self) -> kv::Info { + kv::Info::new( Scheme::Foundationdb, "foundationdb", Capability { diff --git a/core/src/services/gridfs/backend.rs b/core/src/services/gridfs/backend.rs index 6d7898d1dd9..f2bb2341534 100644 --- a/core/src/services/gridfs/backend.rs +++ b/core/src/services/gridfs/backend.rs @@ -214,8 +214,8 @@ impl Adapter { impl kv::Adapter for Adapter { type Scanner = (); - fn metadata(&self) -> kv::Metadata { - kv::Metadata::new( + fn info(&self) -> kv::Info { + kv::Info::new( Scheme::Gridfs, &format!("{}/{}", self.database, self.bucket), Capability { diff --git a/core/src/services/libsql/backend.rs b/core/src/services/libsql/backend.rs index c0870e37467..233580c78e9 100644 --- a/core/src/services/libsql/backend.rs +++ b/core/src/services/libsql/backend.rs @@ -307,8 +307,8 @@ impl Adapter { impl kv::Adapter for Adapter { type Scanner = (); - fn metadata(&self) -> kv::Metadata { - kv::Metadata::new( + fn info(&self) -> kv::Info { + kv::Info::new( Scheme::Libsql, &self.table, Capability { diff --git a/core/src/services/memcached/backend.rs b/core/src/services/memcached/backend.rs index d0cc42c9211..2b772f713e5 100644 --- a/core/src/services/memcached/backend.rs +++ b/core/src/services/memcached/backend.rs @@ -199,8 +199,8 @@ impl Adapter { impl kv::Adapter for Adapter { type Scanner = (); - fn metadata(&self) -> kv::Metadata { - kv::Metadata::new( + fn info(&self) -> kv::Info { + kv::Info::new( Scheme::Memcached, "memcached", Capability { diff --git a/core/src/services/mongodb/backend.rs b/core/src/services/mongodb/backend.rs index 786c34dbe80..ed5f26a411e 100644 --- a/core/src/services/mongodb/backend.rs +++ b/core/src/services/mongodb/backend.rs @@ -228,8 +228,8 @@ impl Adapter { impl kv::Adapter for Adapter { type Scanner = (); - fn metadata(&self) -> kv::Metadata { - kv::Metadata::new( + fn info(&self) -> kv::Info { + kv::Info::new( Scheme::Mongodb, &format!("{}/{}", self.database, self.collection), Capability { diff --git a/core/src/services/mysql/backend.rs b/core/src/services/mysql/backend.rs index 4569431b7e9..ada294d2669 100644 --- a/core/src/services/mysql/backend.rs +++ b/core/src/services/mysql/backend.rs @@ -190,8 +190,8 @@ impl Adapter { impl kv::Adapter for Adapter { type Scanner = (); - fn metadata(&self) -> kv::Metadata { - kv::Metadata::new( + fn info(&self) -> kv::Info { + kv::Info::new( Scheme::Mysql, &self.table, Capability { diff --git a/core/src/services/nebula_graph/backend.rs b/core/src/services/nebula_graph/backend.rs index 9c34018bfdb..4d70e3210a7 100644 --- a/core/src/services/nebula_graph/backend.rs +++ b/core/src/services/nebula_graph/backend.rs @@ -272,8 +272,8 @@ impl Adapter { impl kv::Adapter for Adapter { type Scanner = kv::ScanStdIter>>; - fn metadata(&self) -> kv::Metadata { - kv::Metadata::new( + fn info(&self) -> kv::Info { + kv::Info::new( Scheme::NebulaGraph, &self.session_config.space.clone().unwrap(), Capability { diff --git a/core/src/services/persy/backend.rs b/core/src/services/persy/backend.rs index e5317b11221..c9234f1878c 100644 --- a/core/src/services/persy/backend.rs +++ b/core/src/services/persy/backend.rs @@ -154,8 +154,8 @@ impl Debug for Adapter { impl kv::Adapter for Adapter { type Scanner = (); - fn metadata(&self) -> kv::Metadata { - kv::Metadata::new( + fn info(&self) -> kv::Info { + kv::Info::new( Scheme::Persy, &self.datafile, Capability { diff --git a/core/src/services/postgresql/backend.rs b/core/src/services/postgresql/backend.rs index b7cbacc997a..72993c3af6a 100644 --- a/core/src/services/postgresql/backend.rs +++ b/core/src/services/postgresql/backend.rs @@ -189,8 +189,8 @@ impl Adapter { impl kv::Adapter for Adapter { type Scanner = (); - fn metadata(&self) -> kv::Metadata { - kv::Metadata::new( + fn info(&self) -> kv::Info { + kv::Info::new( Scheme::Postgresql, &self.table, Capability { diff --git a/core/src/services/redb/backend.rs b/core/src/services/redb/backend.rs index 281a5ac96a4..b0722f824ce 100644 --- a/core/src/services/redb/backend.rs +++ b/core/src/services/redb/backend.rs @@ -113,8 +113,8 @@ impl Debug for Adapter { impl kv::Adapter for Adapter { type Scanner = (); - fn metadata(&self) -> kv::Metadata { - kv::Metadata::new( + fn info(&self) -> kv::Info { + kv::Info::new( Scheme::Redb, &self.datadir, Capability { diff --git a/core/src/services/redis/backend.rs b/core/src/services/redis/backend.rs index e04f5af29da..19afe34c765 100644 --- a/core/src/services/redis/backend.rs +++ b/core/src/services/redis/backend.rs @@ -329,8 +329,8 @@ impl Adapter { impl kv::Adapter for Adapter { type Scanner = (); - fn metadata(&self) -> kv::Metadata { - kv::Metadata::new( + fn info(&self) -> kv::Info { + kv::Info::new( Scheme::Redis, self.addr.as_str(), Capability { diff --git a/core/src/services/rocksdb/backend.rs b/core/src/services/rocksdb/backend.rs index ecbf9bdfcf0..8dc3c6d2a2b 100644 --- a/core/src/services/rocksdb/backend.rs +++ b/core/src/services/rocksdb/backend.rs @@ -110,8 +110,8 @@ impl Debug for Adapter { impl kv::Adapter for Adapter { type Scanner = kv::Scanner; - fn metadata(&self) -> kv::Metadata { - kv::Metadata::new( + fn info(&self) -> kv::Info { + kv::Info::new( Scheme::Rocksdb, &self.db.path().to_string_lossy(), Capability { diff --git a/core/src/services/sled/backend.rs b/core/src/services/sled/backend.rs index c4cb4bdf854..64c4c367581 100644 --- a/core/src/services/sled/backend.rs +++ b/core/src/services/sled/backend.rs @@ -139,8 +139,8 @@ impl Debug for Adapter { impl kv::Adapter for Adapter { type Scanner = kv::Scanner; - fn metadata(&self) -> kv::Metadata { - kv::Metadata::new( + fn info(&self) -> kv::Info { + kv::Info::new( Scheme::Sled, &self.datadir, Capability { diff --git a/core/src/services/sqlite/backend.rs b/core/src/services/sqlite/backend.rs index 06158048341..6f9c1aa1553 100644 --- a/core/src/services/sqlite/backend.rs +++ b/core/src/services/sqlite/backend.rs @@ -224,8 +224,8 @@ impl kv::Scan for SqliteScanner { impl kv::Adapter for Adapter { type Scanner = SqliteScanner; - fn metadata(&self) -> kv::Metadata { - kv::Metadata::new( + fn info(&self) -> kv::Info { + kv::Info::new( Scheme::Sqlite, &self.table, Capability { diff --git a/core/src/services/surrealdb/backend.rs b/core/src/services/surrealdb/backend.rs index 47b91e36057..d7de7725268 100644 --- a/core/src/services/surrealdb/backend.rs +++ b/core/src/services/surrealdb/backend.rs @@ -285,8 +285,8 @@ impl Adapter { impl kv::Adapter for Adapter { type Scanner = (); - fn metadata(&self) -> kv::Metadata { - kv::Metadata::new( + fn info(&self) -> kv::Info { + kv::Info::new( Scheme::Surrealdb, &self.table, Capability { diff --git a/core/src/services/tikv/backend.rs b/core/src/services/tikv/backend.rs index 275dcf9bbdc..5d37b526d5d 100644 --- a/core/src/services/tikv/backend.rs +++ b/core/src/services/tikv/backend.rs @@ -187,8 +187,8 @@ impl Adapter { impl kv::Adapter for Adapter { type Scanner = (); - fn metadata(&self) -> kv::Metadata { - kv::Metadata::new( + fn info(&self) -> kv::Info { + kv::Info::new( Scheme::Tikv, "TiKV", Capability {