Class NettyChannelFactory
java.lang.Object
net.devh.boot.grpc.client.channelfactory.AbstractChannelFactory<NettyChannelBuilder>
net.devh.boot.grpc.client.channelfactory.NettyChannelFactory
- All Implemented Interfaces:
AutoCloseable,GrpcChannelFactory
This channel factory creates and manages netty based
GrpcChannelFactorys.
This class utilizes connection pooling and thus needs to be closed after usage.
-
Field Summary
Fields inherited from class net.devh.boot.grpc.client.channelfactory.AbstractChannelFactory
channelConfigurers, globalClientInterceptorRegistry -
Constructor Summary
ConstructorsConstructorDescriptionNettyChannelFactory(GrpcChannelsProperties properties, GlobalClientInterceptorRegistry globalClientInterceptorRegistry, List<GrpcChannelConfigurer> channelConfigurers) Creates a new GrpcChannelFactory for netty with the given options. -
Method Summary
Modifier and TypeMethodDescriptionprotected static voidconfigureAcceptedServerCertificates(GrpcChannelProperties.Security security, io.netty.handler.ssl.SslContextBuilder sslContextBuilder) Configures the server certificates accepted by the ssl context.protected static voidconfigureProvidedClientCertificate(GrpcChannelProperties.Security security, io.netty.handler.ssl.SslContextBuilder sslContextBuilder) Configures the client certificate provided by the ssl context.protected voidconfigureSecurity(NettyChannelBuilder builder, String name) Configures the security options that should be used by the channel.protected NettyChannelBuildernewChannelBuilder(String name) Creates a newManagedChannelBuilderfor the given client name.protected static NegotiationTypeof(NegotiationType negotiationType) Converts the given negotiation type to netty's negotiation type.Methods inherited from class net.devh.boot.grpc.client.channelfactory.AbstractChannelFactory
close, configure, configureCompression, configureKeepAlive, configureLimits, configureUserAgent, createChannel, createChannel, getConnectivityState, getDefaultScheme, getPropertiesFor, isNonNullAndNonBlank, newManagedChannel, watchConnectivityStateMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface net.devh.boot.grpc.client.channelfactory.GrpcChannelFactory
createChannel
-
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
Description copied from class:AbstractChannelFactoryCreates a newManagedChannelBuilderfor the given client name.- Specified by:
newChannelBuilderin classAbstractChannelFactory<NettyChannelBuilder>- Parameters:
name- The name to create the channel builder for.- Returns:
- The newly created channel builder.
-
configureSecurity
Description copied from class:AbstractChannelFactoryConfigures the security options that should be used by the channel.- Overrides:
configureSecurityin classAbstractChannelFactory<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
Converts the given negotiation type to netty's negotiation type.- Parameters:
negotiationType- The negotiation type to convert.- Returns:
- The converted negotiation type.
-