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.7"
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.7", features = ["instance-aware-counter", "lock", "trypema"] }
Or just turn everything on:
[dependencies]
distkit = { version = "0.7", features = ["full"] }
Redis-backed primitives
Counters, instance-aware counters, locks, and Trypema's Redis and hybrid
providers use a redis::aio::ConnectionManager. Add the Redis client and Tokio
alongside distkit:
[dependencies]
distkit = "0.7"
redis = { version = "1", features = ["aio", "tokio-comp", "connection-manager"] }
tokio = { version = "1", features = ["full"] }
Trypema's local provider runs entirely in-process and does not contact Redis.
The Distkit trypema feature still enables Trypema's Tokio Redis integration so
the Redis and hybrid providers are available from the same module.
Requirements
| Requirement | Version |
|---|---|
| Rust edition | 2024 |
| Redis for counters and locks | 5.0+ |
| Redis for Trypema Redis/hybrid providers | 7.2+ |
| Runtime | Tokio 1.x |
Verify
cargo check

