Skip to content

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

refactor(storage): update lease store interface to use write_condition

Steven Enamakel269fdf820407
diff --git a/crates/openhuman-core/src/storage/lease.rs b/crates/openhuman-core/src/storage/lease.rs
index c294fdcae2..999fa2db8f 100644
--- a/crates/openhuman-core/src/storage/lease.rs
+++ b/crates/openhuman-core/src/storage/lease.rs
@@ -170,18 +170,18 @@ pub trait LeaseStore: Send + Sync {
/// [`LeaseError::Storage`].
async fn holder(&self, key: &str) -> Result<Option<LeaseRecord>, LeaseError>;
- /// The fence a storage driver enforces for `node`'s grant on `key` at
+ /// The condition a storage driver evaluates for `node`'s grant on `key` at
/// `epoch`, when the record lives in the storage ports at all: the
/// record must still name `node` at `epoch`, unreleased. The driver then
/// checks a write against the record in the same atomic step
- /// ([`super::fence::LeaseFence::driver_fence`]). `None` (the default) for
+ /// ([`super::fence::LeaseFence::write_condition`]). `None` (the default) for
/// stores that keep records elsewhere, such as file locks.
- fn driver_fence(
+ fn write_condition(
&self,
_key: &str,
_node: &str,
_epoch: u64,
- ) -> Option<tinystoragedrivers::Fence> {
+ ) -> Option<tinystoragedrivers_types::WriteCondition> {
None
}
}
diff --git a/crates/openhuman-core/src/storage/lease_documents.rs b/crates/openhuman-core/src/storage/lease_documents.rs
index 721b0df2b1..c64e93f3b0 100644
--- a/crates/openhuman-core/src/storage/lease_documents.rs
+++ b/crates/openhuman-core/src/storage/lease_documents.rs
@@ -9,10 +9,9 @@ use std::time::Duration;
use async_trait::async_trait;
use serde::{Deserialize, Serialize};
use serde_json::Value;
-use tinystoragedrivers::{
- CollectionSpec, DocumentStore, Fence, Filter, Key, Precondition, Scope, StorageBackend,
- Version, Versioned, WriteOptions,
-};
+use tinystoragedrivers::{CollectionSpec, Precondition, Scope, StorageBackend};
+use tinystoragedrivers_api::DocumentStore;
+use tinystoragedrivers_types::{Filter, Key, Version, Versioned, WriteCondition, WriteOptions};
use super::lease::{
validate_key, LeaseError, LeaseGrant, LeaseRecord, LeaseStore, CLUSTER_SCOPE, LEASE_COLLECTION,
@@ -399,17 +398,20 @@ impl LeaseStore for DocumentLeases {
Ok(self.read(key).await?.map(|record| record_of(record.doc)))
}
- fn driver_fence(&self, key: &str, node: &str, epoch: u64) -> Option<Fence> {
+ fn driver_fence(&self, key: &str, node: &str, epoch: u64) -> Option<WriteCondition> {
let scope = self.scope.clone()?;
let id = Key::of([LEASE_OWNER, key]).ok()?;
- Some(Fence::new(
+ WriteCondition::new(
scope,
LEASE_COLLECTION,
id.as_str().to_string(),
Filter::eq("epoch", epoch)
.and(Filter::eq("holder", node.to_string()))
.and(Filter::exists("released", false)),
- ))
+ )
+ .ok()?
+ .with_valid_until_field("expires_ms")
+ .ok()
}
}