aboutsummaryrefslogtreecommitdiff
path: root/src/k2v-client/lib.rs
diff options
context:
space:
mode:
authortrinity-1686a <trinity@deuxfleurs.fr>2023-06-24 10:17:20 +0200
committertrinity-1686a <trinity@deuxfleurs.fr>2023-06-24 10:17:20 +0200
commit33b3cf8e227048525918b7f232fc250e44dc2d47 (patch)
tree1f05b6c1842afe6e0f78f1e4ea722315c1ba2afc /src/k2v-client/lib.rs
parent736083063fb4f78e9d00d9f3279f902bd3a6aa0a (diff)
downloadgarage-33b3cf8e227048525918b7f232fc250e44dc2d47.tar.gz
garage-33b3cf8e227048525918b7f232fc250e44dc2d47.zip
introduce dedicated return type for PollRange
Diffstat (limited to 'src/k2v-client/lib.rs')
-rw-r--r--src/k2v-client/lib.rs17
1 files changed, 15 insertions, 2 deletions
diff --git a/src/k2v-client/lib.rs b/src/k2v-client/lib.rs
index 425c351f..4aa7a20a 100644
--- a/src/k2v-client/lib.rs
+++ b/src/k2v-client/lib.rs
@@ -182,7 +182,7 @@ impl K2vClient {
filter: Option<PollRangeFilter<'_>>,
seen_marker: Option<&str>,
timeout: Option<Duration>,
- ) -> Result<Option<(BTreeMap<String, CausalValue>, String)>, Error> {
+ ) -> Result<Option<PollRangeResult>, Error> {
let timeout = timeout.unwrap_or(DEFAULT_POLL_TIMEOUT);
let request = PollRangeRequest {
@@ -217,7 +217,10 @@ impl K2vClient {
})
.collect::<BTreeMap<_, _>>();
- Ok(Some((items, resp.seen_marker)))
+ Ok(Some(PollRangeResult {
+ items,
+ seen_marker: resp.seen_marker,
+ }))
}
/// Perform an InsertItem request, inserting a value for a single pk+sk.
@@ -570,6 +573,7 @@ pub struct Filter<'a> {
pub reverse: bool,
}
+/// Filter for a poll range operations.
#[derive(Debug, Default, Clone, Serialize)]
pub struct PollRangeFilter<'a> {
pub start: Option<&'a str>,
@@ -577,6 +581,15 @@ pub struct PollRangeFilter<'a> {
pub prefix: Option<&'a str>,
}
+/// Response to a poll_range query
+#[derive(Debug, Default, Clone, Serialize)]
+pub struct PollRangeResult {
+ /// List of items that have changed since last PollRange call.
+ pub items: BTreeMap<String, CausalValue>,
+ /// opaque string representing items already seen for future PollRange calls.
+ pub seen_marker: String,
+}
+
#[derive(Debug, Clone, Serialize)]
#[serde(rename_all = "camelCase")]
struct PollRangeRequest<'a> {