Kind: Interface
Source: packages/microservices/errors/invalid-grpc-message-decorator.exception.ts
Part of: Microservices
RpcDecoratorMetadata describes the metadata required for an RPC decorator in the microservices layer. It identifies the target gRPC service, RPC method, and streaming mode so validation and error handling can report invalid decorator configurations consistently.
Properties
| Property | Type |
|---|---|
service | string |
rpc | string |
streaming | string |
Diagram
mermaidgraph LR Decorator[RPC Decorator] --> Metadata[RpcDecoratorMetadata] Metadata --> Service[service: gRPC service name] Metadata --> Rpc[rpc: RPC method name] Metadata --> Streaming[streaming: streaming mode] Metadata --> Validation[Decorator validation / error reporting]
Usage
tsimport type { RpcDecoratorMetadata } from './errors/invalid-grpc-message-decorator.exception';
const metadata: RpcDecoratorMetadata = {
service: 'UsersService',
rpc: 'GetUser',
streaming: 'unary',
};
function validateRpcDecorator(config: RpcDecoratorMetadata) {
if (!config.service || !config.rpc) {
throw new Error('RPC decorators must define a service and RPC method.');
}
return config;
}
validateRpcDecorator(metadata);
AI Coding Instructions
- Provide all three fields—
service,rpc, andstreaming—when creatingRpcDecoratorMetadata. - Keep
serviceandrpcaligned with the names defined in the associated gRPC.protocontract. - Use a consistent streaming value that matches the RPC method type, such as unary, client-streaming, server-streaming, or bidirectional streaming.
- Use this interface when constructing validation errors for invalid gRPC message decorators rather than passing untyped metadata objects.
Relationships
- IMPORTS →
RuntimeException
Was this page helpful?