Skip to content

The fastest, cheapest, most efficient open-source agent harness. Run more than 500 agents on a $10 VPS.

refactor(modules): update storage driver imports and types

Steven Enamakel99684d9ff4f6
diff --git a/crates/openhuman-core/src/modules/mod.rs b/crates/openhuman-core/src/modules/mod.rs
index bc53fcfbf8..b6bf6d0058 100644
--- a/crates/openhuman-core/src/modules/mod.rs
+++ b/crates/openhuman-core/src/modules/mod.rs
@@ -102,6 +102,7 @@ pub(crate) mod storage_host;
#[cfg(feature = "modules")]
mod storage_host_linked;
#[cfg(all(test, feature = "modules"))]
+#[cfg(test)]
mod storage_host_watching;
#[cfg(feature = "modules")]
mod storage_import_support;
diff --git a/crates/openhuman-core/src/modules/storage_host_bus_tests.rs b/crates/openhuman-core/src/modules/storage_host_bus_tests.rs
index b14b761a44..a9696c2b5b 100644
--- a/crates/openhuman-core/src/modules/storage_host_bus_tests.rs
+++ b/crates/openhuman-core/src/modules/storage_host_bus_tests.rs
@@ -53,7 +53,8 @@ async fn a_module_write_under_a_stale_lease_is_fenced_by_the_host() {
use std::sync::atomic::{AtomicU64, Ordering};
use std::time::Duration;
- let shared: Arc<dyn StorageBackend> = Arc::new(MemoryStorage::new());
+ let shared: Arc<dyn StorageBackend> =
+ Arc::new(tinystoragedrivers_testkit::MemoryBackend::new());
let clock = Arc::new(AtomicU64::new(0));
let reading = Arc::clone(&clock);
let fences = Arc::new(FenceRegistry::new(move || reading.load(Ordering::SeqCst)));
diff --git a/crates/openhuman-core/src/modules/storage_host_endpoint.rs b/crates/openhuman-core/src/modules/storage_host_endpoint.rs
index 9b6bcac930..1df0b2b3ca 100644
--- a/crates/openhuman-core/src/modules/storage_host_endpoint.rs
+++ b/crates/openhuman-core/src/modules/storage_host_endpoint.rs
@@ -7,7 +7,7 @@ use std::sync::Arc;
use async_trait::async_trait;
use serde_json::Value;
use tinybus::BusName;
-use tinystoragedrivers::BlobReader;
+use tinystoragedrivers_api::BlobReader;
use tinystoragedrivers_bus::{BlobKeyRequest, BlobStreamHead, PutBlobStreamRequest, WatchChanged};
use tinystoragedrivers_busproxy::{HostFailure, StorageCall, StorageEndpoint};
use tokio::sync::broadcast;
diff --git a/crates/openhuman-core/src/modules/storage_host_watching.rs b/crates/openhuman-core/src/modules/storage_host_watching.rs
index f3ad29f1d3..17401c75c3 100644
--- a/crates/openhuman-core/src/modules/storage_host_watching.rs
+++ b/crates/openhuman-core/src/modules/storage_host_watching.rs
@@ -10,10 +10,13 @@ use std::collections::HashMap;
use std::sync::{Arc, Mutex};
use serde_json::Value;
-use tinystoragedrivers::{
- async_trait, Capabilities, Capability, CollectionSpec, DocumentStore, DocumentWatch, Filter,
- MemoryStorage, Page, Precondition, Query, Result, Scope, ScopedStorage, Sort, StorageBackend,
- Version, Versioned, WatchNotice, WatchOptions, WriteOp, WriteResult,
+use tinystoragedrivers_api::{
+ async_trait, DocumentStore, DocumentWatch, Storage, StorageBackend,
+};
+use tinystoragedrivers_testkit::MemoryBackend;
+use tinystoragedrivers_types::{
+ Capabilities, Capability, CollectionSpec, Filter, Page, Precondition, Query, Result, Scope,
+ Sort, Version, Versioned, WatchNotice, WatchOptions, WriteOp, WriteResult,
};
use tokio::sync::broadcast;
@@ -22,7 +25,7 @@ type Hub = Arc<Mutex<HashMap<String, broadcast::Sender<()>>>>;
/// Memory storage with a native document watch.
#[derive(Debug, Default)]
pub(super) struct WatchingStorage {
- inner: MemoryStorage,
+ inner: MemoryBackend,
hub: Hub,
}
@@ -33,15 +36,11 @@ impl WatchingStorage {
}
impl StorageBackend for WatchingStorage {
- fn driver(&self) -> &'static str {
- "memory"
- }
-
fn capabilities(&self) -> Capabilities {
self.inner.capabilities().with(Capability::Watch)
}
- fn for_scope(&self, scope: &Scope) -> Result<ScopedStorage> {
+ fn for_scope(&self, scope: &Scope) -> Result<Storage> {
let scoped = self.inner.for_scope(scope)?;
let sender = {
let mut hub = self.hub.lock().unwrap();
@@ -49,15 +48,16 @@ impl StorageBackend for WatchingStorage {
.or_insert_with(|| broadcast::channel(64).0)
.clone()
};
- Ok(ScopedStorage::new(
- scope.clone(),
- "memory",
+ Ok(Storage::new(
Arc::new(Documents {
inner: Arc::clone(scoped.documents()),
changed: sender,
}),
Arc::clone(scoped.streams()),
+ Arc::clone(scoped.kv()),
Arc::clone(scoped.blobs()),
+ Arc::clone(scoped.queues()),
+ Arc::clone(scoped.secrets()),
))
}
}
@@ -118,7 +118,7 @@ impl DocumentStore for Documents {
id: &str,
doc: Value,
p: Precondition,
- options: tinystoragedrivers::WriteOptions,
+ options: tinystoragedrivers_types::WriteOptions,
) -> Result<Version> {
let version = self.inner.put_with(c, id, doc, p, options).await?;
let _ = self.changed.send(());