Introduction
What Ulo is made of, how an application starts, and which pages to read in which order.
An Ulo application is a tree of modules. A module binds providers (services the container builds), controllers (structs whose methods answer requests, messages or calls) and the other modules it imports. Handlers name what they need in their signature, and the container supplies it.
Three choices are made in main, outside the module tree:
| Choice | Crate | Decides |
|---|---|---|
| Runtime | ulo-runtime-tokio or ulo-runtime-smol | Where tasks run and what the clock is |
| Server | ulo-http-hyper, ulo-rpc-nats, ulo-grpc, ... | Which protocol the application speaks, and on which socket |
| Listener | ulo-listener-tokio or ulo-listener-smol | Which sockets the hyper-based servers accept on. ulo-http-hyper's default tokio feature picks the tokio listener. Without the feature, the server is written ServerOn<L> over the listener chosen |
An application module does not name any of them, so the same module runs under a test, on tokio or on smol.
The five phases
main starts an application in phases, each a method on the value the previous one returned:
App::builder(AppModule) -> .runtime(..) -> .wire()? -> .connect().await? -> .bind(server) -> .listen().await? -> .serve(signal).await?| Phase | What happens | What can fail |
|---|---|---|
wire | Checks the whole module graph: visibility, scopes, cycles, duplicates. No instance is built and no I/O happens. | Every wiring problem, reported together |
connect | Builds the singletons (one instance per application; see Scopes), runs readiness checks and the init and bootstrap hooks | A provider that fails to build, a hook that errors |
bind | Registers a server for the application to serve on | |
listen | Prepares every server, then acquires the sockets | Every server's configuration problem together, then port conflicts |
serve | Runs until the signal future resolves or close is called, then drains |
A job or a command stops after connect, runs work with execute, and calls close. Example 12-standalone shows this; see Standalone executions.
Where to read next
- Installation: dependency lines, Rust versions.
- Quick Start: a running route.
- Project Structure: what
ulo newwrites. - Development Workflow:
ulo dev. - Coming from NestJS, if the model is familiar.