Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
[submodule "sdk"]
path = sdk
url = https://github.com/G-Core/FastEdge-sdk-rust.git
[submodule "crates/reactor/wit"]
path = crates/reactor/wit
url = https://github.com/G-Core/FastEdge-wit.git
19 changes: 12 additions & 7 deletions crates/key-value-store/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@ pub use redis_impl::RedisStore;
pub trait Store: Sync + Send {
async fn get(&self, key: &str) -> Result<Option<Value>, Error>;

async fn zrange(&self, key: &str, min: f64, max: f64) -> Result<Vec<Value>, Error>;
async fn zrange_by_score(
&self,
key: &str,
min: f64,
max: f64,
) -> Result<Vec<(Value, f64)>, Error>;

async fn scan(&self, pattern: &str) -> Result<Vec<String>, Error>;

Expand Down Expand Up @@ -64,15 +69,15 @@ impl key_value::HostStore for KeyValueStore {
KeyValueStore::scan(self, store_id, &pattern).await
}

async fn zrange(
async fn zrange_by_score(
&mut self,
store: Resource<key_value::Store>,
key: String,
min: f64,
max: f64,
) -> Result<Vec<Value>, Error> {
) -> Result<Vec<(Value, f64)>, Error> {
let store_id = store.rep();
KeyValueStore::zrange(self, store_id, &key, min, max).await
KeyValueStore::zrange_by_score(self, store_id, &key, min, max).await
}

async fn zscan(
Expand Down Expand Up @@ -135,17 +140,17 @@ impl KeyValueStore {

/// Get a values from a store by key.
#[instrument(skip(self), level = "trace", ret, err)]
pub async fn zrange(
pub async fn zrange_by_score(
&self,
store: u32,
key: &str,
min: f64,
max: f64,
) -> Result<Vec<Value>, Error> {
) -> Result<Vec<(Value, f64)>, Error> {
let Some(store) = self.stores.get(store as usize) else {
return Err(Error::NoSuchStore);
};
store.zrange(key, min, max).await
store.zrange_by_score(key, min, max).await
}

#[instrument(skip(self), level = "trace", ret, err)]
Expand Down
9 changes: 7 additions & 2 deletions crates/key-value-store/src/redis_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,15 @@ impl Store for RedisStore {
})
}

async fn zrange(&self, key: &str, min: f64, max: f64) -> Result<Vec<Value>, Error> {
async fn zrange_by_score(
&self,
key: &str,
min: f64,
max: f64,
) -> Result<Vec<(Value, f64)>, Error> {
self.inner
.clone()
.zrangebyscore(key, min, max)
.zrangebyscore_withscores(key, min, max)
.await
.map_err(|error| {
tracing::warn!(cause=?error, "redis zrangebyscore");
Expand Down
2 changes: 1 addition & 1 deletion crates/reactor/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#![allow(missing_docs)]

wasmtime::component::bindgen!({
path: "../../sdk/wit",
path: "wit",
world: "reactor",
imports: { default: async },
});
1 change: 1 addition & 0 deletions crates/reactor/wit
Submodule wit added at 561aa9
1 change: 0 additions & 1 deletion sdk
Submodule sdk deleted from 67ae2a
Loading