# RpcDecoratorMetadata

**Kind:** Interface

**Source:** [`packages/microservices/errors/invalid-grpc-message-decorator.exception.ts`](https://github.com/nestjs/nest/blob/master/packages/microservices/errors/invalid-grpc-message-decorator.exception.ts#L3)

**Part of:** [Microservices](subsystem-packages-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

```mermaid
graph 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

```ts
import 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`, and `streaming`—when creating `RpcDecoratorMetadata`.
- Keep `service` and `rpc` aligned with the names defined in the associated gRPC `.proto` contract.
- 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`
