quarkus-google-cloud-services icon indicating copy to clipboard operation
quarkus-google-cloud-services copied to clipboard

Feature: provide TransportChannelProvider as CDI bean?

Open jfbenckhuijsen opened this issue 1 year ago • 7 comments

Hi,

As per https://docs.quarkiverse.io/quarkus-google-cloud-services/main/pubsub.html, we would need to provide a specific channel provider in case an emulator is used via the dev-service. Would it be an idea to provide the correct TransportChannelProvider as a CDI bean. Then the application logic can stay the same between production and emulator usage, and the toggle would just be based upon quarkus.google.cloud.pubsub.emulator-host having a value.

If it has no value, provide the default (see Publisher.Builder):

TopicAdminSettings.defaultGrpcTransportProviderBuilder().setChannelsPerCpu(1.0).build()

, otherwise

// Create a ChannelProvider that connects to the Dev Service
ManagedChannel channel = ManagedChannelBuilder.forTarget(emulatorHost).usePlaintext().build();
channelProvider = FixedTransportChannelProvider.create(GrpcTransportChannel.create(channel));

And have the user of the extension always use setChannelProvider().

If needed I can easily create a PR for this.

jfbenckhuijsen avatar Jan 09 '24 21:01 jfbenckhuijsen

Anyone able to respond to this?

jfbenckhuijsen avatar Feb 02 '24 15:02 jfbenckhuijsen

Sorry for not responding early.

I have somewhere a prototype to provide helper methods for PubSub to avoid too much boilerplate and handle this kind of stuff. I'll have a look next week wether I can finish it or not.

loicmathieu avatar Feb 02 '24 15:02 loicmathieu

Cool, if not, let me know. I have an app with quite some integration code which I’d happily see back in the extension instead of maintaining it myself. Or adapt that code to the stuff you’ve been working on.

jfbenckhuijsen avatar Feb 02 '24 15:02 jfbenckhuijsen

@jfbenckhuijsen see https://github.com/quarkiverse/quarkus-google-cloud-services/pull/577 it provides a QuarkusPubSub that allow passing an emulator host to work with a PubSub emulator.

It also provides convenience methods to creates topics, subscription, publisher, ...

Would it fixes your issue?

loicmathieu avatar Feb 09 '24 17:02 loicmathieu

Looks like it would fix it, ill test it in my code

jfbenckhuijsen avatar Feb 16 '24 14:02 jfbenckhuijsen

Just saw one use case which isn't handled: creating a Publisher for a topic in a different project. Ill create a PR for that

jfbenckhuijsen avatar Mar 28 '24 09:03 jfbenckhuijsen

#604

jfbenckhuijsen avatar Mar 28 '24 09:03 jfbenckhuijsen

PR merged, closing as done

jfbenckhuijsen avatar Aug 21 '24 21:08 jfbenckhuijsen