einride / protoc-gen-typescript-http

Generate types and service clients from protobuf definitions annotated with http rules.
MIT License
44 stars 10 forks source link

Server-side streaming support #126

Open aimuz opened 1 year ago

aimuz commented 1 year ago

grpc-gateway supports Server-side streaming.

Server-side streaming is also supported by fetch.

https://developer.mozilla.org/en-US/docs/Web/API/Streams_API/Using_readable_streams

The current protoc-gen-typescript-http has problems with clients generated by Server-side streaming.

protoc-gen-typescript-http

export interface LoggingService {
  QueryLogs(request: QueryLogsRequest): Promise<QueryLogsResponse>;
}

service.proto

service LoggingService {
  rpc QueryLogs(QueryLogsRequest) returns (QueryLogsResponse) {
    option (google.api.http) = {
      get: "/v1beta1/{parent=projects/*}/logs:query"
    };
    option (google.api.method_signature) = "parent";
  }

  rpc TailLogs(TailLogsRequest) returns (stream TailLogsResponse) {
    option (google.api.http) = {
      get: "/v1beta1/{parent=projects/*}/logs:tail"
    };
    option (google.api.method_signature) = "parent";
  }
}
ericwenn commented 1 year ago

This plugin does not yet support server-side streaming, as we have not had a use-case for it. If you feel up for adding that support, please go ahead!