Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
onyn opened this issue Apr 25, 2024 · 1 comment
Open

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

onyn opened this issue Apr 25, 2024 · 1 comment
Assignees
Labels
C-feature-accepted Category: Feature discussed and accepted

Comments

@onyn
Copy link

onyn commented Apr 25, 2024

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
# Generated by the protocol buffer compiler (roadrunner-server/grpc). DO NOT EDIT!
# source: hello.proto

namespace GRPC\Hello;

use Spiral\RoadRunner\GRPC;

interface HelloServiceInterface extends GRPC\ServiceInterface
{
    // GRPC specific service name.
    public const NAME = "hello.HelloService";

    /**
    * @param GRPC\ContextInterface $ctx
    * @param HelloRequest $in
    * @return HelloResponse
    *
    * @throws GRPC\Exception\InvokeException
    */
    public function SayHello(GRPC\ContextInterface $ctx, HelloRequest $in): HelloResponse;

    /**
    * @param GRPC\ContextInterface $ctx
    * @param HelloRequest $in
    * @return HelloResponse
    *
    * @throws GRPC\Exception\InvokeException
    */
    public function LotsOfReplies(GRPC\ContextInterface $ctx, HelloRequest $in): HelloResponse;

    /**
    * @param GRPC\ContextInterface $ctx
    * @param HelloRequest $in
    * @return HelloResponse
    *
    * @throws GRPC\Exception\InvokeException
    */
    public function LotsOfGreetings(GRPC\ContextInterface $ctx, HelloRequest $in): HelloResponse;

    /**
    * @param GRPC\ContextInterface $ctx
    * @param HelloRequest $in
    * @return HelloResponse
    *
    * @throws GRPC\Exception\InvokeException
    */
    public function BidiHello(GRPC\ContextInterface $ctx, HelloRequest $in): HelloResponse;
}

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.

@onyn onyn added the C-feature-request Category: feature requested, but need to be discussed label Apr 25, 2024
@rustatian
Copy link
Member

Hey @onyn 馃憢
Thanks for the feature request 馃憤

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

@rustatian rustatian added C-feature-accepted Category: Feature discussed and accepted and removed C-feature-request Category: feature requested, but need to be discussed labels Apr 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-feature-accepted Category: Feature discussed and accepted
Projects
Status: 馃搵 Backlog
Development

No branches or pull requests

2 participants