roadrunner-server / roadrunner

🤯 High-performance PHP application server, process manager written in Go and powered with plugins
https://docs.roadrunner.dev
MIT License
7.83k stars 407 forks source link

[💡 FEATURE REQUEST]: Add support for streaming RPCs #1906

Open onyn opened 4 months ago

onyn commented 4 months ago

Plugin

GRPC

I have an idea!

In GRPC there are four kinds of service methods:

service HelloService {

  // Unary RPC. This is most common and familiar "request-response" scheme.
  rpc SayHello(HelloRequest) returns (HelloResponse);

  // Server streaming RPC. Client emit single request and receive sequence
  // of messages from server. This is useful for "server push" notifications.
  //
  // Example: chat service in which client subscribes to some room and
  // eventually receive chat messages from there.
  //
  // Example 2: client subscribes for market stock quotes and receives price
  // updates on interested shares.
  rpc LotsOfReplies(HelloRequest) returns (stream HelloResponse);

  // Client streaming RPC. Client send to to server sequence of messages.
  //
  // Example: client send log events which server collects in memory. Once
  // required number of messages have been collected, server flush them into
  // database using single effective bulk operation.
  rpc LotsOfGreetings(stream HelloRequest) returns (HelloResponse);

  // Bidirectional streaming RPC. Combination of previous two.
  rpc BidiHello(stream HelloRequest) returns (stream HelloResponse);
}

Currently roadrunner supports just unary one. If there was streams in proto definition, they turns into unary in the generated interface:

Reveal HelloServiceInterface ```php

Requested functionality is very similar to one offered by centrifugo.

I also found #923, but that seems about streaming large body of single request or response. Not about RPC streams.

rustatian commented 4 months ago

Hey @onyn 👋 Thanks for the feature request 👍

923 is about streaming in general. But for gRPC it is fine to have a separate ticket.