Mocking a gRPC service
Right-click a folder ▸ Add ▸ gRPC server.
Configuring
Section titled “Configuring”Each mocked method is a list entry:
| Field | Role |
|---|---|
| Service / Method | What is served |
| Call type | unary, server-stream, client-stream, bidirectional-stream |
| Response message | The message returned, in JSON — a JSON array for a stream, each element being one frame |
| Status code | 0 for OK, or any other gRPC code |
| Status message | The message that goes with it |
| Trailing metadata | The trailers |
| Script | JavaScript, which wins over the response message |

Mocking an error
Section titled “Mocking an error”This is the most rewarding use: reproducing the status codes your client has to know how to handle.
| Code | Useful for testing |
|---|---|
4 DEADLINE_EXCEEDED | Behaviour when a deadline is exceeded |
8 RESOURCE_EXHAUSTED | Rate limiting |
14 UNAVAILABLE | Fallback and retry |
16 UNAUTHENTICATED | Token renewal |
Fill in the code, the message and the trailing metadata, then check your client reacts correctly.
Streams
Section titled “Streams”For a streaming mode, the response message is a JSON array: each element is sent as its own frame.
Reflection
Section titled “Reflection”The server exposes the gRPC reflection service by default. Your clients —
including grpcurl and Restorm’s own
reflection import — can therefore discover
the service without a .proto.
Two fields, tlsCertPem and tlsKeyPem, accept a certificate and a key in PEM
form, for serving over TLS.
In a scenario
Section titled “In a scenario”The gRPC server and gRPC server close actions. See Hosted servers.