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
GrpcChannelFactory
s.
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 void
configureAcceptedServerCertificates
(GrpcChannelProperties.Security security, io.netty.handler.ssl.SslContextBuilder sslContextBuilder) Configures the server certificates accepted by the ssl context.protected static void
configureProvidedClientCertificate
(GrpcChannelProperties.Security security, io.netty.handler.ssl.SslContextBuilder sslContextBuilder) Configures the client certificate provided by the ssl context.protected void
configureSecurity
(NettyChannelBuilder builder, String name) Configures the security options that should be used by the channel.protected NettyChannelBuilder
newChannelBuilder
(String name) Creates a newManagedChannelBuilder
for the given client name.protected static NegotiationType
of
(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, watchConnectivityState
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods 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:AbstractChannelFactory
Creates a newManagedChannelBuilder
for the given client name.- Specified by:
newChannelBuilder
in classAbstractChannelFactory<NettyChannelBuilder>
- Parameters:
name
- The name to create the channel builder for.- Returns:
- The newly created channel builder.
-
configureSecurity
Description copied from class:AbstractChannelFactory
Configures the security options that should be used by the channel.- Overrides:
configureSecurity
in 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.
-