Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Batch subscriber #148

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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: 2 additions & 4 deletions chitchat-test/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ impl Api {
#[oai(path = "/set_kv/", method = "get")]
async fn set_kv(&self, key: Query<String>, value: Query<String>) -> Json<serde_json::Value> {
let mut chitchat_guard = self.chitchat.lock().await;

let cc_state = chitchat_guard.self_node_state();
let mut cc_state = chitchat_guard.self_node_state();
cc_state.set(key.as_str(), value.as_str());

Json(serde_json::to_value(&SetKeyValueResponse { status: true }).unwrap())
Expand All @@ -48,8 +47,7 @@ impl Api {
#[oai(path = "/mark_for_deletion/", method = "get")]
async fn mark_for_deletion(&self, key: Query<String>) -> Json<serde_json::Value> {
let mut chitchat_guard = self.chitchat.lock().await;

let cc_state = chitchat_guard.self_node_state();
let mut cc_state = chitchat_guard.self_node_state();
cc_state.delete(key.as_str());
Json(serde_json::to_value(&SetKeyValueResponse { status: true }).unwrap())
}
Expand Down
12 changes: 7 additions & 5 deletions chitchat/src/delta.rs
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ impl Delta {
pub(crate) fn num_tuples(&self) -> usize {
self.node_deltas
.iter()
.map(|node_delta| node_delta.num_tuples())
.map(|node_delta| node_delta.key_values.len())
.sum()
}

Expand Down Expand Up @@ -323,10 +323,12 @@ pub(crate) struct NodeDelta {
pub max_version: Option<Version>,
}

#[cfg(test)]
impl NodeDelta {
pub fn num_tuples(&self) -> usize {
self.key_values.len()
impl IntoIterator for NodeDelta {
type Item = KeyValueMutation;
type IntoIter = std::vec::IntoIter<Self::Item>;

fn into_iter(self) -> Self::IntoIter {
self.key_values.into_iter()
}
}

Expand Down
Loading
Loading