ulo
A Rust framework for server applications that serve more than one kind of client. HTTP routes, WebSocket gateways, RPC handlers, gRPC services and GraphQL resolvers are declared on plain structs, share one dependency-injection container, one configuration, one set of health probes and one shutdown, and run on a runtime and a server you choose.
The core owns no async runtime and no socket. A runtime crate (ulo-runtime-tokio,
ulo-runtime-smol) and a transport crate (ulo-http-hyper, ulo-rpc-nats, ...) are added beside it,
so the same application module runs on either runtime and behind any server. A runtime written
outside this repository runs ulo-runtime-conformance, the suite both runtimes pass.
Install
0.1.0-alpha.3 is the current release, on crates.io. Each crate is pinned with =, since a caret
on a pre-release also takes a later alpha, which may break this one:
[]
= "=0.1.0-alpha.3"
= "=0.1.0-alpha.3"
= "=0.1.0-alpha.3"
= "=0.1.0-alpha.3"
= { = "1", = ["derive"] }
= { = "1", = ["macros", "rt-multi-thread"] }
Quick start
A module, one controller with one route, and the phases that start an application. This is
examples/01-hello in one file.
use ;
use Server;
use ;
;
;
async
cargo run, then curl http://127.0.0.1:3000/. wire checks the whole module graph and reports
every problem at once, connect builds the providers and runs their hooks, listen acquires the
sockets, and serve runs until the signal future resolves, then drains.
A handler names what it needs in its signature. Extractors read and validate the request, and a
provider is injected as Dep<T> (examples/15-http-requests is the full version of this):
use Mutex;
use ;
use ;
use ;
;
#
What it serves
| Transport | Crates |
|---|---|
| HTTP | ulo-http with a server: ulo-http-hyper (the reference), or ulo-http-axum, ulo-http-actix, ulo-http-poem, ulo-http-rocket, ulo-http-salvo. TLS through ulo-net. |
| WebSocket | ulo-ws with ulo-ws-hyper; ulo-ws-redis carries a broadcast across processes. |
| RPC | ulo-rpc over TCP (ulo-rpc-tcp, ulo-rpc-tcp-smol), UDP (ulo-rpc-udp), NATS, Redis, MQTT, RabbitMQ or Kafka (ulo-rpc-nats, -redis, -mqtt, -rabbitmq, -kafka). Each link passes ulo-rpc-conformance, the suite a link written outside this repository runs too. |
| gRPC | ulo-grpc, with ulo-build generating the service shapes from a .proto. |
| GraphQL | ulo-graphql over HTTP and WebSocket, with ulo-graphql-async-graphql or ulo-graphql-juniper. |
Around them: ulo-config (layered configuration), ulo-health with ulo-health-http and
ulo-health-grpc (probes), ulo-db with ulo-db-sqlx, -seaorm, -diesel, -mongodb and
-redis (a database as a module), ulo-otel with ulo-otel-otlp (trace context across
transports), and ulo-cli (ulo new, ulo generate, ulo dev).
Will it work for me
- Rust 1.88 is the floor for the workspace. Five crates need more:
ulo-http-salvo1.92,ulo-graphql-async-graphqlandulo-db-diesel1.89,ulo-db-sqlxandulo-db-seaorm1.94. - Runtimes: tokio and smol. Which one an application runs on is a line in
main; example 22 is example 01 on smol. - Without macros: every macro expands to calls on a public value API, so an application can be written without them (example 14).
- Testing:
TestAppbuilds the production module graph with parts replaced (example 13). ulo-rpc-kafkabuilds librdkafka and needs a C toolchain.
Where to go next
The repository, https://github.com/ulo-rs/ulo, holds the design in
docs/experiments/di-redesign/DESIGN.md and forty-one runnable examples in examples/, one concept
each, from 01-hello to 41-one-guard-two-transports. cargo doc --open renders the API docs.
License
MIT.