Skip to content

Commit

Permalink
fix miss in-process
Browse files Browse the repository at this point in the history
  • Loading branch information
shalk committed May 20, 2024
1 parent e52df51 commit f141a8c
Showing 1 changed file with 37 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -143,13 +143,13 @@ List<GrpcChannelConfigurer> defaultChannelConfigurers() {
return Collections.emptyList();
}

// First try the shaded netty channel factory
// First try the shaded netty channel factory and in process factory
@ConditionalOnMissingBean(GrpcChannelFactory.class)
@ConditionalOnClass(name = {"io.grpc.netty.shaded.io.netty.channel.Channel",
"io.grpc.netty.shaded.io.grpc.netty.NettyChannelBuilder"})
"io.grpc.netty.shaded.io.grpc.netty.NettyChannelBuilder", "io.grpc.inprocess.InProcessChannelBuilder"})
@Bean
@Lazy
GrpcChannelFactory shadedNettyGrpcChannelFactory(
GrpcChannelFactory inProcessOrShadedNettyGrpcChannelFactory(
final GrpcChannelsProperties properties,
final GlobalClientInterceptorRegistry globalClientInterceptorRegistry,
final List<GrpcChannelConfigurer> channelConfigurers) {
Expand All @@ -162,12 +162,13 @@ GrpcChannelFactory shadedNettyGrpcChannelFactory(
return new InProcessOrAlternativeChannelFactory(properties, inProcessChannelFactory, channelFactory);
}

// Then try the normal netty channel factory
// Then try the normal netty channel factory and in process factory
@ConditionalOnMissingBean(GrpcChannelFactory.class)
@ConditionalOnClass(name = {"io.netty.channel.Channel", "io.grpc.netty.NettyChannelBuilder"})
@ConditionalOnClass(name = {"io.netty.channel.Channel", "io.grpc.netty.NettyChannelBuilder",
"io.grpc.inprocess.InProcessChannelBuilder"})
@Bean
@Lazy
GrpcChannelFactory nettyGrpcChannelFactory(
GrpcChannelFactory inProcessOrNettyGrpcChannelFactory(
final GrpcChannelsProperties properties,
final GlobalClientInterceptorRegistry globalClientInterceptorRegistry,
final List<GrpcChannelConfigurer> channelConfigurers) {
Expand All @@ -180,8 +181,38 @@ GrpcChannelFactory nettyGrpcChannelFactory(
return new InProcessOrAlternativeChannelFactory(properties, inProcessChannelFactory, channelFactory);
}

// Then try the shaded netty channel factory
@ConditionalOnMissingBean(GrpcChannelFactory.class)
@ConditionalOnClass(name = {"io.grpc.netty.shaded.io.netty.channel.Channel",
"io.grpc.netty.shaded.io.grpc.netty.NettyChannelBuilder"})
@Bean
@Lazy
GrpcChannelFactory shadedNettyGrpcChannelFactory(
final GrpcChannelsProperties properties,
final GlobalClientInterceptorRegistry globalClientInterceptorRegistry,
final List<GrpcChannelConfigurer> channelConfigurers) {

log.info("Detected grpc-netty-shaded: Creating ShadedNettyChannelFactory");
return new ShadedNettyChannelFactory(properties, globalClientInterceptorRegistry, channelConfigurers);
}

// Then try the normal netty channel factory
@ConditionalOnMissingBean(GrpcChannelFactory.class)
@ConditionalOnClass(name = {"io.netty.channel.Channel", "io.grpc.netty.NettyChannelBuilder"})
@Bean
@Lazy
GrpcChannelFactory nettyGrpcChannelFactory(
final GrpcChannelsProperties properties,
final GlobalClientInterceptorRegistry globalClientInterceptorRegistry,
final List<GrpcChannelConfigurer> channelConfigurers) {

log.info("Detected grpc-netty: Creating NettyChannelFactory");
return new NettyChannelFactory(properties, globalClientInterceptorRegistry, channelConfigurers);
}

// Finally try the in process channel factory
@ConditionalOnMissingBean(GrpcChannelFactory.class)
@ConditionalOnClass(name = {"io.grpc.inprocess.InProcessChannelBuilder"})
@Bean
@Lazy
GrpcChannelFactory inProcessGrpcChannelFactory(
Expand Down

0 comments on commit f141a8c

Please sign in to comment.