Modular, reusable middleware for Rust network clients and servers
open sourceMITfree
Tower is a Rust library of modular, reusable components for building robust networking clients and servers. Its core is the Service trait, an asynchronous function from a request to a response or an error, which models clients and servers alike; generic components such as timeouts, rate limiting and load balancing are services that wrap an inner service, and the Layer trait and ServiceBuilder compose this middleware in a protocol-agnostic way. On its own it isn't a network client or server: libraries that implement protocols such as HTTP depend on tower-service so users can add any Tower middleware. It's split into tower, tower-service and tower-layer (the stable core traits) and tower-test. Not to be confused with the Git client Tower.
Problems it solves
- add timeouts, rate limiting and load balancing to my Rust service's requests
- write middleware once and reuse it across my Rust clients and servers
- build a protocol-agnostic request/response pipeline in async Rust
Features
- Service trait: an async function from request to response or error
- Layer trait and ServiceBuilder for composing middleware
- middleware for timeouts, rate limiting and load balancing
- tower-test crate for testing code that uses Tower
