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

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

RequirementVersion
Rust edition2024
Redis5.0+ (Lua scripts)
RuntimeTokio 1.x

Verify

cargo check

Next steps