Skip to content

reat: Bi-Directional Streaming APIs could use BidiRpc base class by default #979

Open
@tswast

Description

@tswast

Is your feature request related to a problem? Please describe.

I'm trying to implement some fixes for the BigQuery Storage API Write client in googleapis/python-bigquery-storage#278 so that it's easier to use from a multi-threaded environment.

The current interface for bi-directional streaming APIs takes an iterable of requests and returns an iterable of responses. For long-running streams, it's on the consumer of this API to ensure they have a background thread consuming the responses as they write requests to the the input iterable (e.g. via a generator).

It would be preferable if the API instead provided a way to open the stream with an initial request and then subsequently call send/recv on the stream (this it the interface provided by BidiRpc

Better yet, if the API guarantees one response message per request message, then having send return a future object would an even more natural experience. (This is the case for the API which I'm trying to wrap).

Better further still would be that the generated client could handle flow control, heartbeats, and stream resumption as is done manually in Pub/Sub, Pub/Sub Lite, and Firestore.

Describe the solution you'd like

At the very least, automatically wrap Bi-Directional streaming APIs in the BidiRpc class, for a more natural streaming API when working with multiple threads (which you basically have to do unless you somehow interlace iterating over the response iterator while you're generating requests).

Describe alternatives you've considered

Status quo means we basically have to make a manual client whenever an API has a Bi-Directional streaming method.

Additional context

Metadata

Metadata

Assignees

No one assigned

    Labels

    priority: p3Desirable enhancement or fix. May not be included in next release.type: feature request‘Nice-to-have’ improvement, new feature or different behavior or design.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions