From 9a16b724d5f8c6ad822aa81c8963f8facf83ad7f Mon Sep 17 00:00:00 2001 From: Alejandro Cabeza Romero Date: Wed, 11 Dec 2024 19:49:08 +0100 Subject: [PATCH] Implement StorageBackend for SurrealDB --- nomos-services/storage/Cargo.toml | 1 + nomos-services/storage/src/backends/surrealdb.rs | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/nomos-services/storage/Cargo.toml b/nomos-services/storage/Cargo.toml index 763dfe9c..522771db 100644 --- a/nomos-services/storage/Cargo.toml +++ b/nomos-services/storage/Cargo.toml @@ -17,6 +17,7 @@ rocksdb = { version = "0.22", optional = true } surrealdb = { version = "2.1.2", optional = true } thiserror = "1.0" tracing = "0.1" +serde_json = "1.0.133" [dev-dependencies] tokio = { version = "1", features = ["sync", "macros", "time"] } diff --git a/nomos-services/storage/src/backends/surrealdb.rs b/nomos-services/storage/src/backends/surrealdb.rs index 63138aae..cc49ca04 100644 --- a/nomos-services/storage/src/backends/surrealdb.rs +++ b/nomos-services/storage/src/backends/surrealdb.rs @@ -112,7 +112,7 @@ where async fn load(&mut self, key: &[u8]) -> Result, Self::Error> { let key = from_utf8(key)?; - let record: Option = self.db.select(("kv", key)).await?; + let record: Option = self.db.select(("kv", key)).await?; // TODO: Fix kv Ok(record.as_ref().map(Data::to_bytes)) } @@ -146,7 +146,7 @@ mod tests { use crate::backends::testing::NoStorageSerde; use tokio::runtime::Handle; - fn get_test_config() -> SurrealBackendSettings { + pub fn get_test_config() -> SurrealBackendSettings { let (sender, _) = tokio::sync::mpsc::channel(1); SurrealBackendSettings::new( String::from("mem://"),