FAQ
Hybrid application
HTTP and message transports in one process.
The question: Can one application answer HTTP requests and also consume messages from a broker?
Yes. One container serves HTTP and one or more microservice transports at once, sharing the same providers (services, repositories, caches):
val app = Kest.run<AppModule>(args)
app.http(NettyHttpAdapter(8080)) // REST for browsers
app.microservice(NatsServer("nats://nats:4222", queue = "orders")) // messages from other servicesBoth entry points call the same OrderService, with the same guards and validation applying to each. You can add app.grpc(...), a WebSocket gateway and GraphQL on the same container too.
When it is a good idea
- A service that has a public API and reacts to events from the rest of the system.
- You want one deployable unit and one set of business logic.
When to split it
If the HTTP part and the message part need different scaling (many HTTP replicas, few consumers) or different release cycles, run them as two applications that share a library (Libraries), using the same AppModule or a smaller module each. kest new --template worker creates a worker with no HTTP.
Shutdown
Closing the container (SIGTERM) stops every server and transport, in reverse order, running lifecycle hooks.