tower only.Expand description
Tower interoperability (tower feature): adapters between rws’s own
Application/Middleware and the
Tower Service/Layer traits, so tonic gRPC
services and tower-http layers work in an rws app, and an rws app works in
a Tower stack. rws itself doesn’t run on Tower: its request path stays the
native one, and nothing here is compiled without the feature.
TowerApp/mount— a Tower service (a tonic server, a tower-httpServeDir, an axumRouter) as an rwsApplication.TowerLayer— a Tower layer (tower-http’sSetResponseHeader,ValidateRequestHeader,Timeout, …) as rws middleware.TowerService— an rws app as a Tower service, for hyper or axum.
Requests and responses cross as http::Request<Body> /
http::Response<Body> (Body implements http_body::Body).
Tower futures run on one process-wide runtime, rws-tower (2 threads):
tokio I/O and timers belong to the runtime that made them, and an rws
handler may run under the shared runtime, a per-core one or none at all.
Its threads have no trace context, so automatic client spans
(crate::otel) don’t nest under requests a Tower service answers.
Structs§
- Body
- The
http_body::Bodyrws hands to Tower and gets back from its own handlers: bytes in one frame, or chunks (and trailers) from a channel. - Mount
- What
mountreturns. - Next
- The rest of the rws stack, as the Tower service a layer wraps.
- Tower
App - A Tower service as an rws
Application: every request goes to it.mountputs one under a path prefix in front of another app. - Tower
Layer - A Tower
Layer— tower-http’sSetResponseHeaderLayer,ValidateRequestHeaderLayer,TimeoutLayer,NormalizePathLayer, … — as rwsMiddleware:app.wrap(TowerLayer::new(layer)). - Tower
Service - An rws
Applicationas a TowerService<http::Request<B>>— to serve it with hyper, or nest it in an axumRouter(Router::fallback_service).
Functions§
- from_
http_ request - An
http::Requestas an rws request, its body read into memory. - from_
http_ response - An
http::Responseas an rws response. A body that’s gRPC, or of unknown or large size, streams throughstream_pipe(polled onrws-tower), its trailers inResponse::trailers; small ones are collected. - mount
- Requests whose path starts with
prefixgo toservice, the rest tofallback. - to_
http_ request - An rws request as an
http::Request(body as given). - to_
http_ response - An rws response as an
http::Response: buffered bodies in one frame, files and pipes streamed (read on therws-towerblocking pool), withResponse::trailersafter them.
Type Aliases§
- BoxError
- The error type bodies and services are converted to.