tower-rust

Implements Rust middleware and services with tower Service, Layer, and ServiceBuilder patterns.

2|Updated May 16, 2026
One-click install
npx skills add https://github.com/avbel/ai-skills --skill tower-rust-avbel
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: tower-rust
Source: https://github.com/avbel/ai-skills/tree/main/skills/tower-rust
Command: npx skills add https://github.com/avbel/ai-skills --skill tower-rust-avbel

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes scripts (resource) components.

What problem does it solve? Building correct Tower-based services in Rust requires understanding readiness, backpressure, and middleware ordering, and mistakes like calling a service before it is ready cause panics or hidden overload behavior. ## Core Features & Use Cases - Service and Layer Conventions: Enforces correct poll_ready/call patterns, readiness delegation, and explicit error and future types when implementing Service and Layer. - Middleware Stack Guidance: Covers ServiceBuilder ordering, timeouts, concurrency and rate limits, load shedding, buffers, and explicit retry Policy implementations. - Framework Integration: Explains how Tower services integrate with axum, tonic, and hyper, including error conversion at framework boundaries. - Use Case: When adding a timeout and concurrency limit to an axum router, apply the recommended ServiceBuilder stack ordering and convert middleware errors into HTTP responses. ## Quick Start Ask the agent to review or write a Tower service or middleware stack in Rust, for example to add a timeout, concurrency limit, and load shedding around an existing service.

Frequently Asked Questions about tower-rust

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I add timeout and concurrency limit middleware in tower Rust?▼

Use ServiceBuilder to stack middleware, for example .load_shed().concurrency_limit(64).timeout(Duration::from_secs(5)) before your inner service. Enable the timeout, limit, and load-shed features in Cargo.toml and keep ordering intentional.

How do I implement the tower Service trait in Rust?▼

Implement Service with associated Response, Error, and Future types, returning Poll::Ready(Ok(())) from poll_ready and producing the response future in call. Always drive readiness with svc.ready().await?.call(request).await? before invoking call.

Why does tower Service call panic in my Rust code?▼

Service::call may panic if invoked before poll_ready has returned Poll::Ready(Ok(())). Always await readiness first, and note that a cloned service may not be ready even when the original was.

Can I use tower middleware with axum or tonic?▼

Yes, axum routers and tonic clients and servers are Tower services, so standard middleware applies. Convert middleware failures into HTTP responses for axum or tonic::Status for gRPC before they cross the framework boundary.

When should I not use tower for a Rust service?▼

Tower fits request/response protocols like HTTP, gRPC, and RPC, but it is the wrong core abstraction for fully stream-based protocols without discrete requests and responses. Also note tower itself is not no_std, unlike tower-layer and tower-service.