diff --git a/examples/microprofile/grpc/src/main/resources/application.yaml b/examples/microprofile/grpc/src/main/resources/application.yaml index 6dff1ae28f4..fdc488cfd16 100644 --- a/examples/microprofile/grpc/src/main/resources/application.yaml +++ b/examples/microprofile/grpc/src/main/resources/application.yaml @@ -30,18 +30,19 @@ server: resource-path: "server.p12" grpc: - channels: - string-channel: - port: 0 - tls: - trust: - keystore: - passphrase: "password" - trust-store: true - resource: - resource-path: "client.p12" - private-key: - keystore: - passphrase: "password" - resource: - resource-path: "client.p12" \ No newline at end of file + client: + channels: + - name: "string-channel" + port: 0 + tls: + trust: + keystore: + passphrase: "password" + trust-store: true + resource: + resource-path: "client.p12" + private-key: + keystore: + passphrase: "password" + resource: + resource-path: "client.p12" \ No newline at end of file diff --git a/microprofile/grpc/client/src/main/java/io/helidon/microprofile/grpc/client/ChannelProducer.java b/microprofile/grpc/client/src/main/java/io/helidon/microprofile/grpc/client/ChannelProducer.java index c29525e06b4..9a1cb1f3c5f 100644 --- a/microprofile/grpc/client/src/main/java/io/helidon/microprofile/grpc/client/ChannelProducer.java +++ b/microprofile/grpc/client/src/main/java/io/helidon/microprofile/grpc/client/ChannelProducer.java @@ -47,7 +47,7 @@ public class ChannelProducer { */ @Inject ChannelProducer(Config config) { - provider = GrpcChannelsProvider.create(config.get("grpc")); + provider = GrpcChannelsProvider.create(config.get("grpc.client")); } /** diff --git a/microprofile/grpc/client/src/main/java/io/helidon/microprofile/grpc/client/GrpcChannelDescriptorBlueprint.java b/microprofile/grpc/client/src/main/java/io/helidon/microprofile/grpc/client/GrpcChannelDescriptorBlueprint.java index 74d77fcadf1..54e7b8da1a9 100644 --- a/microprofile/grpc/client/src/main/java/io/helidon/microprofile/grpc/client/GrpcChannelDescriptorBlueprint.java +++ b/microprofile/grpc/client/src/main/java/io/helidon/microprofile/grpc/client/GrpcChannelDescriptorBlueprint.java @@ -26,6 +26,14 @@ @Prototype.Configured interface GrpcChannelDescriptorBlueprint { + /** + * The name of this channel. + * + * @return channel name + */ + @Option.Configured + String name(); + /** * The host to connect to. * diff --git a/microprofile/grpc/client/src/main/java/io/helidon/microprofile/grpc/client/GrpcChannelsDescriptorBlueprint.java b/microprofile/grpc/client/src/main/java/io/helidon/microprofile/grpc/client/GrpcChannelsDescriptorBlueprint.java new file mode 100644 index 00000000000..c6932921197 --- /dev/null +++ b/microprofile/grpc/client/src/main/java/io/helidon/microprofile/grpc/client/GrpcChannelsDescriptorBlueprint.java @@ -0,0 +1,35 @@ +/* + * Copyright (c) 2024 Oracle and/or its affiliates. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package io.helidon.microprofile.grpc.client; + +import java.util.List; + +import io.helidon.builder.api.Option; +import io.helidon.builder.api.Prototype; + +@Prototype.Blueprint +@Prototype.Configured +interface GrpcChannelsDescriptorBlueprint { + + /** + * List of channel descriptors. + * + * @return channel descriptors + */ + @Option.Configured + List channels(); +} diff --git a/microprofile/grpc/client/src/main/java/io/helidon/microprofile/grpc/client/GrpcChannelsProvider.java b/microprofile/grpc/client/src/main/java/io/helidon/microprofile/grpc/client/GrpcChannelsProvider.java index 0ad6c5aeb3b..85fd849bd54 100644 --- a/microprofile/grpc/client/src/main/java/io/helidon/microprofile/grpc/client/GrpcChannelsProvider.java +++ b/microprofile/grpc/client/src/main/java/io/helidon/microprofile/grpc/client/GrpcChannelsProvider.java @@ -119,7 +119,7 @@ public Channel channel(String name) { throw new IllegalArgumentException("name cannot be empty or blank."); } GrpcChannelDescriptor chCfg = channelConfigs.computeIfAbsent(name, hostName -> - GrpcChannelDescriptor.builder().host(name).build()); + GrpcChannelDescriptor.builder().name(name).host(name).build()); return createChannel(name, chCfg); } @@ -176,20 +176,14 @@ public static class Builder implements io.helidon.common.Builder channelConfigs.put(ch.name(), ch)); } /** diff --git a/microprofile/grpc/client/src/test/resources/application.yaml b/microprofile/grpc/client/src/test/resources/application.yaml index bf73807e8ae..525f7570c65 100644 --- a/microprofile/grpc/client/src/test/resources/application.yaml +++ b/microprofile/grpc/client/src/test/resources/application.yaml @@ -30,18 +30,19 @@ server: resource-path: "server.p12" grpc: - channels: - echo-channel: - port: 0 - tls: - trust: - keystore: - passphrase: "password" - trust-store: true - resource: - resource-path: "client.p12" - private-key: - keystore: - passphrase: "password" - resource: - resource-path: "client.p12" \ No newline at end of file + client: + channels: + - name: "echo-channel" + port: 0 + tls: + trust: + keystore: + passphrase: "password" + trust-store: true + resource: + resource-path: "client.p12" + private-key: + keystore: + passphrase: "password" + resource: + resource-path: "client.p12" \ No newline at end of file