nestrs-microservices
Microservice transports and client proxy for nestrs: request/response and fire-and-forget patterns over optional backends (TCP, NATS, Redis, gRPC, Kafka, MQTT, RabbitMQ — feature-gated).
Also re-exports nestrs_events::EventBus and wires #[on_event] handlers registered via #[event_routes].
Docs: docs.rs/nestrs-microservices · Repo: github.com/Joshyahweh/nestrs
Install
[]
= { = "0.3.6", = ["nats"] }
# or: features = ["redis"], ["kafka"], ["mqtt"], ["rabbitmq"], ["grpc"], etc.
From the umbrella crate you can use:
= { = "0.3.6", = ["microservices", "microservices-nats"] }
Example: ClientProxy over a transport
use ;
use Arc;
async
Handlers are implemented on injectable types using #[micro_routes] + #[message_pattern] / #[event_pattern] (see main nestrs docs).
Per-handler cross-cutting (Nest-like, not identical): #[use_micro_interceptors(...)], #[use_micro_guards(...)], #[use_micro_pipes(...)] — types implement MicroIncomingInterceptor, MicroCanActivate, MicroPipeTransform (see crate docs).
Custom brokers: implement Transport and optionally consume the JSON protocol described in the wire and custom modules.
Wire format stability: golden JSON fixtures live in tests/fixtures/ and are checked by tests/wire_conformance.rs. The doc revision constant is WIRE_FORMAT_DOC_REVISION (bump when changing serde shapes).
gRPC: JSON payloads match wire inside protobuf fields; server dispatch uses the same wire::dispatch_send / dispatch_emit as other transports. Clients: GrpcTransportOptions::new(..).with_request_timeout(..).
RabbitMQ: one work queue (default nestrs.micro) carries wire::WireRequest JSON; request/reply uses a private reply queue name in reply. Bootstrap with NestFactory::create_microservice_rabbitmq when using the umbrella crate feature microservices-rabbitmq.
Features
| Feature | Purpose |
|---|---|
nats |
NATS request/reply + events |
redis |
Redis lists / pub-sub style bridge |
grpc |
gRPC transport |
kafka |
Kafka request topic consumer |
mqtt |
MQTT RPC-style topics |
rabbitmq |
AMQP 0-9-1 via lapin (work queue + reply queues) |
microservice-metrics |
Handler metrics hooks |
License
MIT OR Apache-2.0.