waymaker-client/rust
Michael Netshipise 87a6171969 waymaker-client v0.1.27 — polyglot Go / TypeScript / Rust clients
Extract the waymaker client into a standalone, polyglot repo versioned in
lockstep with the waymaker server (this tag == server v0.1.27).

- proto/   vendored client-facing protos (source of truth: waymaker repo).
           internal_proxy (server-internal ProxyService + replication) is
           intentionally excluded — it is a server concern, not a client one.
- rust/    standalone crate; build.rs generates from proto/. Quorum fence
           scope + Lock auto-reacquire / fence-watch (watch/is_lost) API.
- go/      module git.awesomike.com/pub/waymaker-client/go — generated stubs
           + ergonomic wrappers (locks/streams/kv/collections/sketches/object).
- ts/      @waymaker/client — generated stubs + ergonomic wrappers.
- scripts/ sync-protos.sh (re-vendor + align VERSION) + gen-go.sh + gen-ts.sh.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
2026-06-09 19:20:48 +02:00
..
src waymaker-client v0.1.27 — polyglot Go / TypeScript / Rust clients 2026-06-09 19:20:48 +02:00
Cargo.toml waymaker-client v0.1.27 — polyglot Go / TypeScript / Rust clients 2026-06-09 19:20:48 +02:00
README.md waymaker-client v0.1.27 — polyglot Go / TypeScript / Rust clients 2026-06-09 19:20:48 +02:00
build.rs waymaker-client v0.1.27 — polyglot Go / TypeScript / Rust clients 2026-06-09 19:20:48 +02:00

README.md

waymaker-client (Rust)

Official Rust client for waymaker.

[dependencies]
waymaker-client = { git = "https://git.awesomike.com/pub/waymaker-client", tag = "v0.1.27" }
# (the crate lives in the rust/ subdir; cargo resolves it automatically)

Proto stubs are generated from ../proto at build time via build.rs — no dependency on the waymaker server workspace.

Surfaces

  • lock — read/write locks, leader election, TTL leases. The Lock handle keeps a background task that transparently re-binds its event stream across a primary bounce (reusing the request_id) and exposes live state: lock.fence_token(), lock.watch() (a watch::Receiver<LockState>), lock.is_lost(). Re-read the fence before every fenced side effect.
  • stream — JetStream-lite publish + pull/push consumers.
  • kv — Put/Get/Create/Update(CAS)/Delete/Keys/History/Watch.
  • cache — Redis-shape Hash / Set / Queue (collections).
  • probabilistic — Bloom / HLL / CMS / TopK / t-digest.
  • object — chunked object Put/Get.

Raw generated stubs are available under server / streams_server / kv_server / collections_server / sketches_server / cache_server.

Leader election

use std::time::Duration;
use waymaker_client::{Client, lock};

let client = Client::connect("http://127.0.0.1:8818").await?;
let lock = client.acquire_lock("leader:reports", lock::Config {
    max_wait: Duration::ZERO,            // try-acquire
    lease_ttl: Duration::from_secs(30),
    scope: lock::Scope::Quorum,          // Raft-replicated fence
    ..Default::default()
}).await?;
let _renewal = lock.spawn_renewal(Duration::from_secs(15));

// Re-read the fence before each fenced write; stop if leadership is lost.
let mut state = lock.watch();
loop {
    if lock.is_lost() { break; }
    do_fenced_write(lock.fence_token()).await?;
    state.changed().await.ok();
}