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

Emulator support for Google based client #348

Closed
mmatloka opened this issue Jan 13, 2022 · 5 comments
Closed

Emulator support for Google based client #348

mmatloka opened this issue Jan 13, 2022 · 5 comments

Comments

@mmatloka
Copy link

Hello!
Readme says :

Doesn't work with the official PubSub emulator (is in feature backlog)

Link to that backlog is no longer working. I've looked though google cloud docs and they show here usage of java client with the emulator.

String hostport = System.getenv("PUBSUB_EMULATOR_HOST");
ManagedChannel channel = ManagedChannelBuilder.forTarget(hostport).usePlaintext().build();

Does it mean that this library could be adjusted for emulator support?

@bastewart
Copy link
Contributor

Ah, thanks! Yes this almost certainly does mean we could update this to support the emulator. (FWIW the HTTP variant does support it already.)

@Daenyth
Copy link

Daenyth commented May 20, 2024

https://cloud.google.com/pubsub/docs/emulator#accessing_environment_variables

It's a little more complicated; one issue is that ManagedChannel is a lifecycle'd resource with a shutdown method - you ideally wouldn't create one inside of the customizePublisher etc method, since it wants to return Publisher and not a Resource

I think the cleanest resolution would be to expose an additional emulatorHost: Option[String] field on the PubsubProducerConfig which gets used in GooglePubsubProducer.of (and similarly for subscriber). It might also be nice to read the PUBSUB_EMULATOR_HOST variable automatically, since the non-java gcp sdks do that for you

@alejandrohdezma
Copy link
Contributor

This should no longer be an issue on the new revamped library (fs2-pubsub). Feel free to re-open it in case it is though.

@Daenyth
Copy link

Daenyth commented Jun 6, 2024

@alejandrohdezma How do you do it in the new library? The readme doesn't mention "emulator" at all

@alejandrohdezma
Copy link
Contributor

Hey @Daenyth, the tests are using an emulator and as you can see there, you just need to point the URI to use to one of the emulator and use a non-authenticated client.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants