ulo
ulo
Documentation

Start here

Coming from NestJSNestJS topics, mapped

The model

Protocols

HTTP Serversulo-http-hyperTLSRuntimesEmbeddingaxumactix-websalvopoemrocketWriting a server crate

Integrations

Operating

Reference

HTTP Servers

actix-web

Running an Ulo application inside an actix-web server with ulo-http-actix.

ulo-http-actix is a native embedding: the adapter implements HttpServiceFactory, and the app mounts as a scope or the default service. The app's pipeline runs inside actix's single-threaded workers, so actix's per-core runtime model is kept.

Mounting

use ulo::App;

let server = ulo_http_actix::Embedded::new().nested_at("/api");
let embedded = server.handle();
let app = App::builder(AppModule).runtime(ulo_runtime_tokio::Tokio::current()).wire()?.connect().await?.bind(server).listen().await?;

let host = {
    let embedded = embedded.clone();
    actix_web::HttpServer::new(move || actix_web::App::new().service(ulo_http_actix::scope("/api", &embedded)))
        .bind(("0.0.0.0", 8080))?
};
ulo_http_actix::run(app, &embedded, host, ulo_runtime_tokio::shutdown_signal()).await?;

(From the crate documentation of ulo-http-actix.)

run disables actix's own signal handling, sets shutdown_timeout to the app's drain window rounded up to the second, and stops the server with stop(true) when the app drains. It must be called inside a tokio runtime. scope("", &embedded) mounts the app as the default service.

What it declares

  • No WebSocket upgrades. A gateway on the HTTP port is refused at listen. A gateway declared port = own is served by ulo-ws-hyper, which works beside any host.
  • The app strips the prefix. web::scope leaves the path whole. The adapter declares without_strips_prefix, and the app removes the nested_at prefix.
  • No host extensions. A value in actix's request store reaches the app only through a forward copy over HttpRequest.
  • No miss forwarding and no TLS information.
  • Request payload pumped through a channel. actix's payload is not Send and the app's body is, so a worker-local task pumps it through a bounded channel.
  • No close signal for a call in progress. actix-http keeps running a call whose connection the peer closed, or whose HTTP/2 stream it reset, until the call answers. A handler gets no signal of it beyond a request body still arriving ending with an error. The adapter declares without_pending_close and without_pending_reset.
  • A dropped response body is observed at the next failed write, so an idle stream is not cancelled until it has something to send.
  • OriginalPath is a built-in forward, read from req.path(). Of the app's response extensions, only Routing is copied into actix's own store.

Drain

  • A request whose head is still arriving gets a closed connection rather than the app's 503. From actix-web 4.15 actix's graceful stop reaches every HTTP/1 connection, and one with no complete request in progress closes at once. A request pipelined behind one in flight is dropped the same way.
  • HTTP/2 is DrainHttp2::Reset. The adapter builds actix-web without its http2 feature, so on its own it serves HTTP/1.1. Cargo unifies features: any crate in the application that enables actix-web's http2 turns it on here, and a server listening with listen_auto_h2c or over TLS with ALPN then serves HTTP/2. actix sends such a connection no GOAWAY. It stays open until shutdown_timeout resets it, and the draining app answers its requests 503. The app's close takes the whole window while one is open.

The conformance-http2 feature exists for the conformance suite only. An application serving HTTP/2 enables actix-web's http2 itself.

axum

Running an Ulo application inside an axum server with ulo-http-axum.

salvo

Running an Ulo application inside a salvo server with ulo-http-salvo.

On this page

MountingWhat it declaresDrain