Compare commits

..

1 Commits

Author SHA1 Message Date
Michael Netshipise 14a75f503e waymaker-client v0.1.28 — optional ttl on all sketch reserves
Add ttl: Option<Duration> 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 <noreply@anthropic.com>
2026-06-19 22:37:04 +02:00
8 changed files with 23 additions and 2 deletions

View File

@ -1 +1 @@
0.1.27
0.1.28

View File

@ -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;

View File

@ -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"

View File

@ -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<std::time::Duration>,
}
#[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();

View File

@ -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<std::time::Duration>,
}
#[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();

View File

@ -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<std::time::Duration>,
}
#[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();

View File

@ -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<std::time::Duration>,
}
#[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();

View File

@ -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<std::time::Duration>,
}
#[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();