Hybrid application
A hybrid application serves HTTP requests and, at the same time, listens for messages from one or more microservice transports (Redis, NATS, Kafka, etc.). Corvis does not have microservices yet (see Microservices), so it has no hybrid applications or a method to connect transports to an HTTP application either.
What you can combine in a single application:
- HTTP and WebSockets. Controllers and
#[websocket_gateway]coexist in the same process and the same port, and share providers. Inexamples/tertulia,RoomsServiceis injected into both the gateway and a REST controller, and the controller injects the gateway to push announcements over WebSocket. - HTTP and background tasks.
ScheduleModule(cron, intervals, timeouts) andEventEmitterModulerun inside the same application. See Task scheduling and Events. - A queue consumer of your own. You can start a consume loop (with the broker client you prefer) in a provider's
on_application_bootstrap, withcorvis::tokio::spawn, and stop it inon_application_shutdown. The handlers it calls do not go through guards, pipes or interceptors. - A context without HTTP. For a separate worker process,
CorvisFactory::create_application_context::<M>()creates the DI container without a server. See Standalone applications.