Expand description
§rivet-core
rivet-core is the runtime kernel for rivet composition and dispatch.
§Build Lifecycle Order
ApplicationBuilder::build() executes stages in a deterministic order:
- Configure modules (
RivetModule::configure). - Collect providers from modules.
- Register all providers.
- Boot all providers.
- Collect routes from modules.
- Collect middleware from modules.
If any stage fails, build stops immediately and later stages do not run.
§Middleware Order Semantics
Middleware runs in registration order on the way in and reverse order on the way out.
Given middleware [A, B], execution order is:
A.beforeB.before- terminal dispatch
B.afterA.after
A middleware can short-circuit by returning a response without calling next.
§Build Failure Behavior
Build-time failures return RivetError with deterministic messages.
Primary categories are:
- configure/module failures
- provider register/boot failures
- route collection failures (including duplicates)
The builder is fail-fast and does not attempt partial recovery.
§Dispatch Contract For Adapters
Adapters should treat Dispatcher::dispatch(Request) -> Response as the only dispatch boundary.
Current dispatch behavior:
- matched route:
200 - no route path match:
404 - path match + method mismatch:
405withallowheader HEADfalls back toGETand clears body when no explicitHEADroute exists
Adapter responsibilities remain transport-specific concerns such as timeout, panic boundaries, IO buffering, and protocol translation.
§Observability
Core emits structured tracing events for build stages, route outcomes, middleware execution, and dispatch completion.
Request body contents are intentionally not logged.
§Examples
Run the minimal example:
cargo run -p rivet-core --example minimal_appRun the modular provider example:
cargo run -p rivet-core --example modular_provider_appmodular_provider_app shows a module exposing a service provider that initializes a service in the container during build.
Run the Laravel-style builder example:
cargo run -p rivet-core --example laravel_style_applaravel_style_app demonstrates the fluent bootstrap API:
ApplicationBuilder::configure(..., config)->with_routing(...)->with_middleware(...)->with_exceptions(...)->with_schedule(...)->build().
The simplified API surface used by examples:
Builder::with_defaults()for in-memory container/config bootstrapping.Application::make::<T>()for typed service resolution from the app container.ProviderFactory+with_providers(&[...])for compile-time static provider registries.
Macros§
Structs§
- Application
- Built rivet runtime that implements the dispatch contract.
- Application
Builder - Builder
- Builds an
Applicationfrom rivet modules and foundation backends. - Exception
Config - Middleware
Config - Routing
Config - Schedule
Config
Enums§
- Frequency
- Rivet
Error - Top-level rivet error surface returned by build and dispatch APIs.
Traits§
- Dispatcher
- Runtime dispatch boundary used by adapters.
- Middleware
- Middleware contract for request/response interception around dispatch.
- Rivet
Module - Defines one composable unit of rivet behavior.
Functions§
Type Aliases§
- Provider
Factory - Compile-time provider constructor used by static provider registries.