Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import io.grpc.ClientInterceptor;
import java.util.List;
import java.util.Map;
import lombok.Builder;
import lombok.Singular;
import lombok.Value;
Expand All @@ -12,4 +13,6 @@ public class GrpcChannelConfig {
Integer maxInboundMessageSize;

@Singular List<ClientInterceptor> clientInterceptors;

Map<String, Object> serviceConfig;
}
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ protected ManagedChannel configureAndBuildChannel(
if (config.getMaxInboundMessageSize() != null) {
builder.maxInboundMessageSize(config.getMaxInboundMessageSize());
}
if (config.getServiceConfig() != null) {
builder.defaultServiceConfig(config.getServiceConfig()).enableRetry();
Comment thread
aaron-steinfeld marked this conversation as resolved.
Outdated
}
this.registryConfig.getDefaultInterceptors().forEach(builder::intercept);
return builder.intercept(config.getClientInterceptors()).build();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import io.grpc.ManagedChannel;
import io.grpc.ManagedChannelBuilder;
import java.util.List;
import java.util.Map;
import java.util.concurrent.TimeUnit;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -145,6 +146,21 @@ void copyConstructorReusesExistingChannels() {
assertSame(firstChannel, new GrpcChannelRegistry(firstRegistry).forSecureAddress("foo", 1000));
}

@Test
void createsDistinctChannelsForDifferentServiceConfigs() {
Map<String, Object> serviceConfig = Map.of("methodConfig", List.of());
Channel channelWithServiceConfig =
this.channelRegistry.forSecureAddress(
"foo", 1000, GrpcChannelConfig.builder().serviceConfig(serviceConfig).build());

assertNotNull(channelWithServiceConfig);
assertNotSame(channelWithServiceConfig, this.channelRegistry.forSecureAddress("foo", 1000));
assertSame(
Comment thread
aaron-steinfeld marked this conversation as resolved.
Outdated
channelWithServiceConfig,
this.channelRegistry.forSecureAddress(
"foo", 1000, GrpcChannelConfig.builder().serviceConfig(serviceConfig).build()));
}

@Test
void registersRegistryInterceptors() {
try (MockedStatic<ManagedChannelBuilder> mockedBuilderStatic =
Expand Down
Loading