Getting Started
Installation
Add distkit and turn on only the primitives you need with feature flags.
Add the crate with Cargo:
cargo add distkit
Or pin it in Cargo.toml:
[dependencies]
distkit = "0.5"
This gives you the default features: the strict and lax counters. Everything else is opt-in.
Feature flags
distkit keeps its dependency surface small by gating each primitive behind a feature. Enable what you use.
| Feature | Default | What it adds |
|---|---|---|
counter | yes | Distributed counters (StrictCounter, LaxCounter) |
instance-aware-counter | no | Per-instance counters (StrictInstanceAwareCounter, LaxInstanceAwareCounter) |
lock | no | Distributed locks (Mutex, RwLock) |
trypema | no | Rate limiting via the trypema crate |
full | no | Everything above |
To enable instance-aware counters, locks, and rate limiting:
[dependencies]
distkit = { version = "0.5", features = ["instance-aware-counter", "lock", "trypema"] }
Or just turn everything on:
[dependencies]
distkit = { version = "0.5", features = ["full"] }
You also need Redis and a client
Every primitive talks to Redis through a redis::aio::ConnectionManager, so you need the redis crate and Tokio alongside distkit:
[dependencies]
distkit = "0.5"
redis = { version = "0.27", features = ["tokio-comp", "connection-manager"] }
tokio = { version = "1", features = ["full"] }
Requirements
| Requirement | Version |
|---|---|
| Rust edition | 2024 |
| Redis | 5.0+ (Lua scripts) |
| Runtime | Tokio 1.x |
Verify
cargo check

