distkit
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.

FeatureDefaultWhat it adds
counteryesDistributed counters (StrictCounter, LaxCounter)
instance-aware-counternoPer-instance counters (StrictInstanceAwareCounter, LaxInstanceAwareCounter)
locknoDistributed locks (Mutex, RwLock)
trypemanoRate limiting via the trypema crate
fullnoEverything 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

RequirementVersion
Rust edition2024
Redis for counters and locks5.0+
Redis for Trypema Redis/hybrid providers7.2+
RuntimeTokio 1.x

Verify

cargo check

Next steps