Class NettyChannelFactory

All Implemented Interfaces:
AutoCloseable, GrpcChannelFactory

public class NettyChannelFactory extends AbstractChannelFactory<NettyChannelBuilder>
This channel factory creates and manages netty based GrpcChannelFactorys.

This class utilizes connection pooling and thus needs to be closed after usage.

  • Constructor Details

    • NettyChannelFactory

      public NettyChannelFactory(GrpcChannelsProperties properties, GlobalClientInterceptorRegistry globalClientInterceptorRegistry, List<GrpcChannelConfigurer> channelConfigurers)
      Creates a new GrpcChannelFactory for netty with the given options.
      Parameters:
      properties - The properties for the channels to create.
      globalClientInterceptorRegistry - The interceptor registry to use.
      channelConfigurers - The channel configurers to use. Can be empty.
  • Method Details

    • newChannelBuilder

      protected NettyChannelBuilder newChannelBuilder(String name)
      Description copied from class: AbstractChannelFactory
      Creates a new ManagedChannelBuilder for the given client name.
      Specified by:
      newChannelBuilder in class AbstractChannelFactory<NettyChannelBuilder>
      Parameters:
      name - The name to create the channel builder for.
      Returns:
      The newly created channel builder.
    • configureSecurity

      protected void configureSecurity(NettyChannelBuilder builder, String name)
      Description copied from class: AbstractChannelFactory
      Configures the security options that should be used by the channel.
      Overrides:
      configureSecurity in class AbstractChannelFactory<NettyChannelBuilder>
      Parameters:
      builder - The channel builder to configure.
      name - The name of the client to configure.
    • configureProvidedClientCertificate

      protected static void configureProvidedClientCertificate(GrpcChannelProperties.Security security, io.netty.handler.ssl.SslContextBuilder sslContextBuilder)
      Configures the client certificate provided by the ssl context.
      Parameters:
      security - The security configuration to use.
      sslContextBuilder - The ssl context builder to configure.
    • configureAcceptedServerCertificates

      protected static void configureAcceptedServerCertificates(GrpcChannelProperties.Security security, io.netty.handler.ssl.SslContextBuilder sslContextBuilder)
      Configures the server certificates accepted by the ssl context.
      Parameters:
      security - The security configuration to use.
      sslContextBuilder - The ssl context builder to configure.
    • of

      protected static NegotiationType of(NegotiationType negotiationType)
      Converts the given negotiation type to netty's negotiation type.
      Parameters:
      negotiationType - The negotiation type to convert.
      Returns:
      The converted negotiation type.