Skip to content

About

Rust SDK for clusdr, a distributed coordination runtime. Talks to the local daemon for membership, presence, locks, leases, and events.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

A runtime for the cluster. An SDK for the app.

docs crates.io CI Rust 1.82+ License

Application SDK for the local Clusdr daemon. This crate does not join the cluster.

your process  ──►  clusdr daemon on this host  ──►  the rest of the cluster

Not a database, queue, or Kubernetes. Wire API is v1alpha1. TLS is on by default. Async on Tokio.

Install

[dependencies]
clusdr = "0.2.0"

Same version train as the daemon. A running daemon on this host is required:

curl -fsSL https://clusdr.io/install.sh | sh

Linux amd64/arm64, or Docker Hub durguto/clusdr (GHCR: ghcr.io/clusdr/clusdr). Then clusdr init and clusdr start --bootstrap. Guide: first member.

Use

local dials CLUSDR_GRPC_ADDR or 127.0.0.1:7947, waits on Health, then you own the connection.

use clusdr::{local, Options, WatchFilter};
use std::time::Duration;
use tokio_stream::StreamExt;

#[tokio::main]
async fn main() -> Result<(), clusdr::Error> {
    let c = local(Options::new()).await?;
    let members = c.members().await?;
    let _leader = c.leader().await?;
    let _ = members;

    c.publish("deployment", br#"{"sha":"abc"}"#).await?;

    let lk = c.lock("scheduler", Some(Duration::from_secs(15))).await?;
    let _ = lk.token;
    c.unlock("scheduler").await?;

    let mut events = c.watch(WatchFilter::default()).await?;
    while let Some(event) = events.next().await {
        let event = event?;
        // member.join, leader.changed, custom.deployment, …
        let _ = event.event_type;
        break;
    }

    c.close().await?;
    Ok(())
}

dial is for tests and operators. Apps use local.

One Cluster is cheap to clone (shared connection, same holder). unlock is process-wide for that name. Several Watch streams on one client are fine.

ttl is Option<Duration>. None or zero sends ttl_ms = 0; the daemon uses its default (15s). close stops Watch, unlocks, and revokes what this process still holds. Failures are clusdr::Error.

Full surface: Rust SDK. Runnable copies (Go, Python, Rust, TypeScript, and Java): examples.

TLS

On unless Options::insecure(true) or CLUSDR_TLS=disabled. PEMs (ca.crt, node.crt, node.key) come from data_dir, CLUSDR_DATA_DIR, or ~/.clusdr. Missing files are an error; this client does not skip-verify.

Not in this crate

  • Join, promote, or configure the cluster (CLI)
  • Talking to a remote node's Runtime API as the normal path — put a daemon on that host

Links

Apache-2.0. Contributor checkout: CONTRIBUTING.md.

About

Rust SDK for clusdr, a distributed coordination runtime. Talks to the local daemon for membership, presence, locks, leases, and events.

Topics

Resources

Code of conduct

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages