distkit
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 Mutex and a writer-preferring RwLock that mirror tokio::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 an unwrap in your hot path.
  • Predictable background work. The tasks that flush buffers and renew lock leases hold Weak references, 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