@@ -218,24 +218,33 @@ void discoverInjectedClients(BeanDiscoveryFinishedBuildItem beanDiscovery,
218218 public void generateGrpcClientProducers (List <GrpcClientBuildItem > clients ,
219219 BuildProducer <SyntheticBeanBuildItem > syntheticBeans ) {
220220
221+ // squash all GrpcClientBuildItem's ClientInfo(s) per clientName
222+ // so any extension could add own GrpcClientBuildItem(s) as well
223+ Map <String , Set <ClientInfo >> clientsMap = new HashMap <>();
221224 for (GrpcClientBuildItem client : clients ) {
222- for (ClientInfo clientInfo : client .getClients ()) {
225+ Set <ClientInfo > infos = clientsMap .computeIfAbsent (client .getClientName (), cn -> new HashSet <>());
226+ infos .addAll (client .getClients ());
227+ }
228+
229+ for (Map .Entry <String , Set <ClientInfo >> entry : clientsMap .entrySet ()) {
230+ String clientName = entry .getKey ();
231+ for (ClientInfo clientInfo : entry .getValue ()) {
223232 if (clientInfo .type == ClientType .CHANNEL ) {
224233 // channel
225234
226235 // IMPORTANT: the channel producer relies on the io.quarkus.grpc.runtime.supports.GrpcClientConfigProvider
227236 // bean that provides the GrpcClientConfiguration for the specific service.
228237
229238 ExtendedBeanConfigurator configurator = SyntheticBeanBuildItem .configure (GrpcDotNames .CHANNEL )
230- .addQualifier ().annotation (GrpcDotNames .GRPC_CLIENT ).addValue ("value" , client . getClientName () )
239+ .addQualifier ().annotation (GrpcDotNames .GRPC_CLIENT ).addValue ("value" , clientName )
231240 .done ()
232241 .scope (Singleton .class )
233242 .unremovable ()
234243 .forceApplicationClass ()
235244 .creator (new Consumer <>() {
236245 @ Override
237246 public void accept (MethodCreator mc ) {
238- GrpcClientProcessor .this .generateChannelProducer (mc , client . getClientName () , clientInfo );
247+ GrpcClientProcessor .this .generateChannelProducer (mc , clientName , clientInfo );
239248 }
240249 })
241250 .destroyer (Channels .ChannelDestroyer .class );
@@ -250,7 +259,6 @@ public void accept(MethodCreator mc) {
250259 syntheticBeans .produce (configurator .done ());
251260 } else {
252261 // blocking stub, mutiny stub, mutiny client
253- String clientName = client .getClientName ();
254262 ExtendedBeanConfigurator configurator = SyntheticBeanBuildItem .configure (clientInfo .className )
255263 .addQualifier ().annotation (GrpcDotNames .GRPC_CLIENT ).addValue ("value" , clientName ).done ()
256264 // Only the mutiny client can use the Application scope, the others are "final" and so need Singleton.
0 commit comments