Server streaming

PriceFeed Service

The client asks once, and the server keeps sending a stream of responses over time (e.g. live stock prices).

1 request → many responses

1. The contract

This is real gRPC code. It defines the service and messages.
pricefeed.proto
syntax = "proto3";

package demo;

// SERVER STREAMING: one request, a stream of replies
service PriceFeed {
  rpc Subscribe (SymbolRequest) returns (stream PriceUpdate);
}

message SymbolRequest {
  string symbol = 1;   // e.g. "BTC"
}

message PriceUpdate {
  string symbol = 1;
  double price  = 2;
  string time   = 3;
}

2. Live simulation

Watch how messages flow for this pattern.

// Press the button to start the Server streaming demo.