Key points for gRPC bidirectional streaming with Traffic Parrot:
- There is one or more request and one or more responses per RPC call.
- Traffic Parrot represents this as multiple request/response mappings.
- Each mapping has a MessageNumber in the mapping file that represents the order of the responses.
- Each mapping has a CallId in the mapping file that represents which RPC call the mapping belongs to.
- The request matcher is duplicated for each mapping.
- Each request is matched against the mappings and produces one or more responses.

In this example:
- These mappings form a bidirectional streaming response with 3 response elements sent per request received:
  * $.requestId is the matchesJsonPath request matcher
  * example.01.ProcessStream-Process[OK].json
  * example.02.ProcessStream-Process[OK].json
  * example.03.ProcessStream-Process[OK].json

- This mapping forms a bidirectional streaming response with an error response sent for the first matching request received:
  * {"requestId": "request-error"} is the equalToJson request matcher
  * example.04.ProcessStream-Process[UNAVAILABLE].json
  
- gRPC mappings are placed in the "grpc-mappings" directory
- gRPC proto files are placed in the "proto" directory
- The default non-TLS port is 5552

Sample https://github.com/fullstorydev/grpcurl testing: 

$ grpcurl -proto example.proto -emit-defaults -plaintext -d '{"requestId": "request-1"} {"requestId": "request-2"} {"requestId": "request-3"}' localhost:5552 example.ProcessStream/Process
{
  "requestId": "request-1",
  "state": "ACKNOWLEDGED"
}
{
  "requestId": "request-1",
  "state": "PROCESSING"
}
{
  "requestId": "request-1",
  "state": "PROCESSED"
}
{
  "requestId": "request-2",
  "state": "ACKNOWLEDGED"
}
{
  "requestId": "request-2",
  "state": "PROCESSING"
}
{
  "requestId": "request-2",
  "state": "PROCESSED"
}
{
  "requestId": "request-3",
  "state": "ACKNOWLEDGED"
}
{
  "requestId": "request-3",
  "state": "PROCESSING"
}
{
  "requestId": "request-3",
  "state": "PROCESSED"
}

$ grpcurl -proto example.proto -emit-defaults -plaintext -d '{"requestId": "request-1"} {"requestId": "request-error"} {"requestId": "request-3"}' localhost:5552 example.ProcessStream/Process
{
  "requestId": "request-1",
  "state": "ACKNOWLEDGED"
}
{
  "requestId": "request-1",
  "state": "PROCESSING"
}
{
  "requestId": "request-1",
  "state": "PROCESSED"
}
ERROR:
  Code: Unavailable
  Message: Error Message


For more information please contact support@trafficparrot.com

