quarkus-google-cloud-services
quarkus-google-cloud-services copied to clipboard
Feature: provide TransportChannelProvider as CDI bean?
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.
Anyone able to respond to this?
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.
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 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?
Looks like it would fix it, ill test it in my code
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
#604
PR merged, closing as done