Visualize how gRPC messages flow between client and server
syntax = "proto3";
package trading;
service OrderService {
// Unary RPC
rpc PlaceOrder(OrderRequest) returns (OrderResponse) {}
// Server Streaming RPC
rpc SubscribeOrderUpdates(OrderRequest) returns (stream OrderUpdate) {}
// Client Streaming RPC
rpc PlaceBulkOrders(stream OrderRequest) returns (BulkOrderResponse) {}
// Bidirectional Streaming RPC
rpc StreamOrders(stream OrderRequest) returns (stream OrderResponse) {}
}
message OrderRequest {
int32 user_id = 1;
string product_id = 2;
int32 quantity = 3;
OrderSide side = 4;
string client_order_id = 5;
}
message OrderResponse {
string order_id = 1;
OrderStatus status = 2;
double fill_price = 3;
string timestamp = 4;
}
message OrderUpdate {
string order_id = 1;
OrderStatus status = 2;
double fill_price = 3;
int32 filled_quantity = 4;
string timestamp = 5;
}
message BulkOrderResponse {
repeated OrderResponse orders = 1;
int32 success_count = 2;
int32 failed_count = 3;
}
enum OrderSide {
BUY = 0;
SELL = 1;
}
enum OrderStatus {
NEW = 0;
FILLED = 1;
PARTIALLY_FILLED = 2;
REJECTED = 3;
CANCELLED = 4;
}
This simulator demonstrates the following steps in gRPC communication:
The client initiates an HTTP/2 connection with the server using TCP.
The client invokes a method on the server by sending an HTTP/2 request with a specific path format: /{service}/{method}
The client serializes a Protocol Buffer message into binary format and sends it in the HTTP/2 request body.
The server deserializes the request, processes it, and prepares a response.
The server serializes the response as a Protocol Buffer message and sends it in the HTTP/2 response body.
The client receives and deserializes the response message.