From 14a75f503e862dc10030a41fd6b5d5852cb495f0 Mon Sep 17 00:00:00 2001 From: Michael Netshipise Date: Fri, 19 Jun 2026 22:37:04 +0200 Subject: [PATCH] =?UTF-8?q?waymaker-client=20v0.1.28=20=E2=80=94=20optiona?= =?UTF-8?q?l=20ttl=20on=20all=20sketch=20reserves?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add ttl: Option to Hll/Bloom/Cms/TopK/TDigest configs; create_* sends ttl_ms (0 = never). For time-bucketed sketch keys (rolling-window cardinality etc.) the server auto-evicts, so callers don't hand-purge old buckets. Co-Authored-By: Claude Opus 4.8 --- VERSION | 2 +- proto/sketches.proto | 5 +++++ rust/Cargo.toml | 2 +- rust/src/probabilistic/bloom.rs | 3 +++ rust/src/probabilistic/cms.rs | 3 +++ rust/src/probabilistic/hll.rs | 4 ++++ rust/src/probabilistic/tdigest.rs | 3 +++ rust/src/probabilistic/topk.rs | 3 +++ 8 files changed, 23 insertions(+), 2 deletions(-) diff --git a/VERSION b/VERSION index a2e1aa9..baec65a 100644 --- a/VERSION +++ b/VERSION @@ -1 +1 @@ -0.1.27 +0.1.28 diff --git a/proto/sketches.proto b/proto/sketches.proto index 292e11a..4cf70e1 100644 --- a/proto/sketches.proto +++ b/proto/sketches.proto @@ -72,6 +72,7 @@ message BloomReserveRequest { string name = 1; uint64 capacity = 2; double error_rate = 3; + uint64 ttl_ms = 4; } message BloomReserveResponse { bool success = 1; @@ -146,6 +147,7 @@ message BloomDeleteResponse { message HllReserveRequest { string name = 1; uint32 precision = 2; + uint64 ttl_ms = 3; } message HllReserveResponse { bool success = 1; @@ -194,6 +196,7 @@ message CmsReserveRequest { string name = 1; uint64 width = 2; uint64 depth = 3; + uint64 ttl_ms = 4; } message CmsReserveResponse { bool success = 1; @@ -242,6 +245,7 @@ message TopKReserveRequest { uint64 width = 3; uint64 depth = 4; double decay = 5; + uint64 ttl_ms = 6; } message TopKReserveResponse { bool success = 1; @@ -295,6 +299,7 @@ message TopKDeleteResponse { message TDigestCreateRequest { string name = 1; uint32 compression = 2; + uint64 ttl_ms = 3; } message TDigestCreateResponse { bool success = 1; diff --git a/rust/Cargo.toml b/rust/Cargo.toml index 7eb4542..ce4ef08 100644 --- a/rust/Cargo.toml +++ b/rust/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "waymaker-client" -version = "0.1.27" +version = "0.1.28" edition = "2021" description = "Official Rust client for waymaker — locks, streams, KV, collections, sketches, cache, object store" repository = "https://git.awesomike.com/pub/waymaker-client" diff --git a/rust/src/probabilistic/bloom.rs b/rust/src/probabilistic/bloom.rs index ff9538c..2a36a1c 100644 --- a/rust/src/probabilistic/bloom.rs +++ b/rust/src/probabilistic/bloom.rs @@ -15,6 +15,8 @@ pub struct BloomConfig { /// Target false-positive rate (e.g. 0.01 for 1%). 0.0 = server /// default (0.01). pub error_rate: f64, + /// Optional auto-eviction after this long. `None` = never expires. + pub ttl: Option, } #[derive(Debug, Clone)] @@ -142,6 +144,7 @@ impl Client { name: config.name.clone(), capacity: config.capacity, error_rate: config.error_rate, + ttl_ms: config.ttl.map(|d| d.as_millis() as u64).unwrap_or(0), })) .await? .into_inner(); diff --git a/rust/src/probabilistic/cms.rs b/rust/src/probabilistic/cms.rs index cb2c3ad..0fd146a 100644 --- a/rust/src/probabilistic/cms.rs +++ b/rust/src/probabilistic/cms.rs @@ -17,6 +17,8 @@ pub struct CmsConfig { pub width: u64, /// Sketch depth (rows / hash functions). 0 = server default. pub depth: u64, + /// Optional auto-eviction after this long. `None` = never expires. + pub ttl: Option, } #[derive(Clone)] @@ -80,6 +82,7 @@ impl Client { name: config.name.clone(), width: config.width, depth: config.depth, + ttl_ms: config.ttl.map(|d| d.as_millis() as u64).unwrap_or(0), })) .await? .into_inner(); diff --git a/rust/src/probabilistic/hll.rs b/rust/src/probabilistic/hll.rs index c4b2866..45cba6d 100644 --- a/rust/src/probabilistic/hll.rs +++ b/rust/src/probabilistic/hll.rs @@ -13,6 +13,9 @@ pub struct HllConfig { /// 2^precision = register count. Valid range 4..=18. 0 = /// server default (14, ~16 KB, ~1% error). pub precision: u32, + /// Optional auto-eviction: the server drops this HLL this long after reserve. + /// `None` = never expires. Handy for time-bucketed keys (rolling windows). + pub ttl: Option, } #[derive(Clone)] @@ -91,6 +94,7 @@ impl Client { .hll_reserve(Request::new(HllReserveRequest { name: config.name.clone(), precision: config.precision, + ttl_ms: config.ttl.map(|d| d.as_millis() as u64).unwrap_or(0), })) .await? .into_inner(); diff --git a/rust/src/probabilistic/tdigest.rs b/rust/src/probabilistic/tdigest.rs index 87a06e5..6861c9a 100644 --- a/rust/src/probabilistic/tdigest.rs +++ b/rust/src/probabilistic/tdigest.rs @@ -15,6 +15,8 @@ pub struct TDigestConfig { /// Compression. Higher = better tail accuracy at cost of /// memory. 0 = server default. pub compression: u32, + /// Optional auto-eviction after this long. `None` = never expires. + pub ttl: Option, } #[derive(Clone)] @@ -87,6 +89,7 @@ impl Client { .t_digest_create(Request::new(TDigestCreateRequest { name: config.name.clone(), compression: config.compression, + ttl_ms: config.ttl.map(|d| d.as_millis() as u64).unwrap_or(0), })) .await? .into_inner(); diff --git a/rust/src/probabilistic/topk.rs b/rust/src/probabilistic/topk.rs index 042703a..6345b63 100644 --- a/rust/src/probabilistic/topk.rs +++ b/rust/src/probabilistic/topk.rs @@ -17,6 +17,8 @@ pub struct TopKConfig { pub depth: u64, /// Probability-decay factor (0.0..=1.0). 0 = server default. pub decay: f64, + /// Optional auto-eviction after this long. `None` = never expires. + pub ttl: Option, } #[derive(Debug, Clone)] @@ -105,6 +107,7 @@ impl Client { width: config.width, depth: config.depth, decay: config.decay, + ttl_ms: config.ttl.map(|d| d.as_millis() as u64).unwrap_or(0), })) .await? .into_inner();