Implement StorageBackend for SurrealDB
This commit is contained in:
parent
9e4abcd528
commit
9a16b724d5
|
@ -17,6 +17,7 @@ rocksdb = { version = "0.22", optional = true }
|
||||||
surrealdb = { version = "2.1.2", optional = true }
|
surrealdb = { version = "2.1.2", optional = true }
|
||||||
thiserror = "1.0"
|
thiserror = "1.0"
|
||||||
tracing = "0.1"
|
tracing = "0.1"
|
||||||
|
serde_json = "1.0.133"
|
||||||
|
|
||||||
[dev-dependencies]
|
[dev-dependencies]
|
||||||
tokio = { version = "1", features = ["sync", "macros", "time"] }
|
tokio = { version = "1", features = ["sync", "macros", "time"] }
|
||||||
|
|
|
@ -112,7 +112,7 @@ where
|
||||||
|
|
||||||
async fn load(&mut self, key: &[u8]) -> Result<Option<Bytes>, Self::Error> {
|
async fn load(&mut self, key: &[u8]) -> Result<Option<Bytes>, Self::Error> {
|
||||||
let key = from_utf8(key)?;
|
let key = from_utf8(key)?;
|
||||||
let record: Option<Data> = self.db.select(("kv", key)).await?;
|
let record: Option<Data> = self.db.select(("kv", key)).await?; // TODO: Fix kv
|
||||||
Ok(record.as_ref().map(Data::to_bytes))
|
Ok(record.as_ref().map(Data::to_bytes))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -146,7 +146,7 @@ mod tests {
|
||||||
use crate::backends::testing::NoStorageSerde;
|
use crate::backends::testing::NoStorageSerde;
|
||||||
use tokio::runtime::Handle;
|
use tokio::runtime::Handle;
|
||||||
|
|
||||||
fn get_test_config() -> SurrealBackendSettings {
|
pub fn get_test_config() -> SurrealBackendSettings {
|
||||||
let (sender, _) = tokio::sync::mpsc::channel(1);
|
let (sender, _) = tokio::sync::mpsc::channel(1);
|
||||||
SurrealBackendSettings::new(
|
SurrealBackendSettings::new(
|
||||||
String::from("mem://"),
|
String::from("mem://"),
|
||||||
|
|
Loading…
Reference in New Issue