Microservices
NestJS microservices parity
Which NestJS microservice features Kest has, and where they are.
Kest follows the NestJS microservices model. This table lists each NestJS feature, what Kest has in its place, and where to read about it.
| NestJS | Kest | Status |
|---|---|---|
NestFactory.createMicroservice(AppModule, options) | createMicroservice<AppModule>(options), then listen() and await() | done |
app.connectMicroservice() and app.startAllMicroservices() (hybrid) | connectMicroservice(options), startAllMicroservices(), http(...) | done |
Transport.TCP, Transport.REDIS, Transport.NATS, Transport.MQTT, Transport.KAFKA, Transport.RMQ | TcpOptions, RedisOptions, NatsOptions, MqttOptions, KafkaOptions, RmqOptions | done |
Transport.GRPC (server) | @GrpcMethod, streams, grpc(...) | done |
Transport.GRPC (ClientGrpc) | GrpcClient(host, port, schema, codec): unary, serverStream, clientStream, bidi, by service and method name | done |
| Custom transport strategy | MicroserviceTransport (listen, close) and ClientTransport | done |
@MessagePattern, @EventPattern | @MessagePattern, @EventPattern | done |
Object patterns ({ cmd: 'sum' }) | @MessagePattern("""{"cmd":"sum"}""") and send(mapOf(...)) | done |
@Payload() and @Payload('field') | @Payload and @Payload("field") | done |
@Ctx() and the broker contexts (KafkaContext, RmqContext, NatsContext, MqttContext, RedisContext) | @Ctx, or a parameter of the context type | done |
ClientProxy.send, emit | send, ask (suspend), sendAsync, emit | done |
ClientsModule.register, registerAsync | ClientsModule.register, registerAsync | done |
RpcException with an error object | RpcException(message, status, error) | done |
| Pipes, guards, interceptors and exception filters on handlers | the same pipeline as HTTP, with the message as the request | done |
retryAttempts, retryDelay | the same names on each options class | done |
Kafka groupId, fromBeginning, run options | groupId, fromBeginning; manual commits, dead-letter topic | done |
RabbitMQ noAck, prefetchCount, queueOptions | acknowledgement by hand, prefetch, dead-letter exchange | done |
NATS queue | queue | done |
serializer and deserializer per transport | not yet: the envelope is the NestJS JSON format | gap |
getService (generated typed stubs for gRPC clients) | calls by service and method name; no generated stubs | gap |
Graceful shutdown (enableShutdownHooks) | done: close() stops every transport and the container, and the JVM shutdown hook calls it | done |
| Testing with a microservice in a test module | Testing.createModule, createMicroservice on a free port | done |
Beyond NestJS: supervised consumers and workers that restart when they crash, a heartbeat watchdog, and actors whose mailboxes survive a crash. See Supervision.