Getting Started
Introduction
What distkit is, what it gives you, and the guarantees it makes.
distkit is a toolkit of distributed systems primitives for Rust, backed by Redis. It bundles the pieces async services keep rebuilding by hand:
- Counters - distributed integer counters in strict (immediately consistent) and lax (buffered) flavors.
- Instance-aware counters - counters where each instance owns a slice of the total, with automatic cleanup when an instance dies.
- Distributed locks - a
Mutexand a writer-preferringRwLockthat mirrortokio::sync. - Rate limiting - sliding-window rate limiting via the trypema crate, re-exported under
distkit::trypema.
Everything is async and built for Tokio. Strict operations push their logic into Redis as Lua scripts, so a single round-trip is atomic across every instance sharing the same Redis.
Guarantees
distkit aims to be boring in the best way:
- No unsafe. The crate is
#![forbid(unsafe_code)]. - No panics in library code. Failures come back as a
DistkitError, never anunwrapin your hot path. - Predictable background work. The tasks that flush buffers and renew lock leases hold
Weakreferences, so they shut down on their own when the owning value is dropped.
What you need
- Rust (latest stable; the crate uses edition 2024).
- A reachable Redis instance, 5.0 or newer (Lua scripting is required).
- The Tokio runtime.
Where to go next
- Installation - pick the right feature set.
- Redis setup - build a connection your primitives can share.
- Quickstart - a counter running end to end.

