cloudstate icon indicating copy to clipboard operation
cloudstate copied to clipboard

HTTP trascoding support grpc stream out x SSE (Server-Side-Events)

Open sleipnir opened this issue 5 years ago • 5 comments
trafficstars

I believe that it is possible (and very desirable) that we can define a transcoding grpc to http that supports the sending of data by stream via SSE (server side events). With the support for Stateless functions coming there it would be interesting that we could support the continuous sending of data in an http response via SSE when the user defines a get resource for a grpc service that returns a Stream. I see that it makes no sense to support this for EventSourced but it would be interesting to support this in the case of Stateless functions since we expose all types of supported grpc services (unary, streamed, stream in, stream out). Since AKKA HTTP supports SSE it shouldn't be difficult to map these resources. I believe it would be a revolutionary feature.

sleipnir avatar May 07 '20 16:05 sleipnir

Example Given a gRPC service defined as below:

service TagService {
     rpc GetTags(GetTag) returns (stream Tag) {
        option (google.api.http) = {
          get: "/tags/{issuer_id}"
          }
        };
    }
}

And a client-side request like this:

$ curl -N --http2 -H "Accept:text/event-stream" https://some.address.com/tags/001

So the proxy should keep the connection alive and use the SSE protocol to send the response information

sleipnir avatar May 07 '20 16:05 sleipnir

@sleipnir Sounds like a great request. One could look at the response type and the accept-header to negotiate the feature on/off.

viktorklang avatar May 07 '20 18:05 viktorklang

@viktorklang Yes. The ideal would be to be negotiable

sleipnir avatar May 07 '20 19:05 sleipnir

@sleipnir Very WIP and untested, but have a look at https://github.com/cloudstateio/cloudstate/pull/317/files! :)

viktorklang avatar May 12 '20 19:05 viktorklang

Very nice @viktorklang , I am following your branch :) I will try to test this as it is. Thank you

sleipnir avatar May 12 '20 20:05 sleipnir