Tower supplies Service and Layer traits plus middleware for timeouts, retries, load balancing, and buffering. It targets request-response networking, not pure stream protocols.
Overview
Tower is a Rust library of reusable components for building network clients and servers around an async request-to-response model. The core Service trait represents asynchronous work that takes a request and returns a response or error, usable for both client and server sides.
Middleware such as timeouts, rate limits, retries, load balancing, buffering, and load shedding wrap inner services and compose through the Layer trait. ServiceBuilder chains layers so protocol code stays separate from cross-cutting behavior. Related crates split stable traits (tower-service, tower-layer) from optional middleware in this crate and testing helpers in tower-test.
Tower does not ship a complete server or client by itself; hyper, tonic, warp, and other stacks integrate Service as an extension point. Feature flags enable only the middleware modules you compile. tower-layer and tower-service support no_std environments even though the main crate does not.
Guides on the project site walk through typical composition patterns. Third-party ecosystem pages list integrations with HTTP and RPC stacks.
Key features
- Service trait for async handlers
- Layer-based middleware composition
- ServiceBuilder for stacking layers
- Timeout, retry, and rate limit modules
- Load balancing and discovery helpers
- Buffering and load shedding
- Protocol-agnostic middleware design
- Optional feature-gated middleware crates
Use cases
- Compose HTTP client middleware
- Share logic across Rust network stacks
- Add retries and timeouts uniformly
- Build custom Service middleware