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’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Async client in cloud package #218

Closed
ArcLightSlavik opened this issue Oct 6, 2020 · 3 comments
Closed

Async client in cloud package #218

ArcLightSlavik opened this issue Oct 6, 2020 · 3 comments
Assignees
Labels
api: pubsub Issues related to the googleapis/python-pubsub API. type: question Request for information or clarification. Not an issue.

Comments

@ArcLightSlavik
Copy link

Recently Async clients got added to the repository eg:
https://github.com/googleapis/python-pubsub/blob/master/google/pubsub_v1/services/publisher/async_client.py, https://github.com/googleapis/python-pubsub/blob/master/google/pubsub_v1/services/subscriber/async_client.py.

But these have not been added to the cloud/pubsub.py:
https://github.com/googleapis/python-pubsub/blob/master/google/cloud/pubsub.py

Meaning when doing pip install google-cloud-pubsub==2.1.0 you don't get these async clients.
What's the reason behind this? Is it still in experimental/testing stage?

@product-auto-label product-auto-label bot added the api: pubsub Issues related to the googleapis/python-pubsub API. label Oct 6, 2020
@meredithslota meredithslota added the type: question Request for information or clarification. Not an issue. label Oct 6, 2020
@pamarc
Copy link

pamarc commented Oct 22, 2020

It seems like you can import them with:

from google.pubsub import PublisherAsyncClient

But I don't think they are usable as they are really low-level. You would need to implement your own async streaming pull manager (+async grpc helpers not yet available in api-core). It would be nice to know if this is planned on the client roadmap.

@plamut
Copy link
Contributor

plamut commented Jan 15, 2021

TL; DR - the new async client can be used, but it's a very stripped down version that, at the time of writing, lacks a lot of features.


The PubSub library consists of the autogenerated part used for communicating with the backend API, and a hand-written layer built on top of it that adds additional functionality such as flow control, message batching on publishing, automatic lease management, and such.

A few months ago the autogenerated layer has been migrated to a new code generator, and that change also included a generated async client. In principle, that client can be used, but it's very basic and only supports interacting with the API using native Python coroutines (async def syntax). There is no hand-written layer siting on top of it (at least not yet), thus it's recommended to keep using the other client for now.

If one still wants to experiment with the async client, it can be imported from the generated part of the library:

from google.pubsub_v1.services.subscriber import SubscriberAsyncClient

It's worth noting, however, that this generated part of the library should be considered an implementation detailed and might be moved to another subdirectory without notice. It is thus better to just keep using the stuff from the google.cloud.pubsub namespace.

@plamut
Copy link
Contributor

plamut commented Feb 23, 2021

Closing this, as the question has been answered and there has been no further activity since then - but feel free to come back if you have additional questions.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
api: pubsub Issues related to the googleapis/python-pubsub API. type: question Request for information or clarification. Not an issue.
Projects
None yet
Development

No branches or pull requests

4 participants