public class GrpcChannelProperties extends Object
Modifier and Type | Class and Description |
---|---|
static class |
GrpcChannelProperties.Security
A container with options for the channel's transport security.
|
Constructor and Description |
---|
GrpcChannelProperties() |
Modifier and Type | Method and Description |
---|---|
protected boolean |
canEqual(Object other) |
void |
copyDefaultsFrom(GrpcChannelProperties config)
Copies the defaults from the given configuration.
|
boolean |
equals(Object o) |
URI |
getAddress()
Gets the target address uri.
|
String |
getDefaultLoadBalancingPolicy()
Gets the default load balancing policy this channel should use.
|
Duration |
getImmediateConnectTimeout()
Get the connection timeout at application startup.
|
Duration |
getKeepAliveTime()
Gets the default delay before we send a keepAlive.
|
Duration |
getKeepAliveTimeout()
The default timeout for a keepAlives ping request.
|
DataSize |
getMaxInboundMessageSize()
Gets the maximum message size allowed to be received by the channel.
|
NegotiationType |
getNegotiationType()
Gets the negotiation type to use on the connection.
|
GrpcChannelProperties.Security |
getSecurity()
Gets the options for transport security.
|
Duration |
getShutdownGracePeriod()
Gets the time to wait for the channel to gracefully shutdown.
|
int |
hashCode() |
boolean |
isEnableKeepAlive()
Gets whether keepAlive is enabled.
|
boolean |
isFullStreamDecompression()
Gets whether full-stream decompression of inbound streams should be enabled.
|
boolean |
isKeepAliveWithoutCalls()
Gets whether keepAlive will be performed when there are no outstanding RPC on a connection.
|
void |
setAddress(String address)
Sets the target address uri for the channel.
|
void |
setAddress(URI address)
Set the address uri for the channel.
|
void |
setDefaultLoadBalancingPolicy(String defaultLoadBalancingPolicy)
Sets the default load balancing policy for this channel.
|
void |
setEnableKeepAlive(Boolean enableKeepAlive)
Sets whether keepAlive should be enabled.
|
void |
setFullStreamDecompression(Boolean fullStreamDecompression)
Sets whether full-stream decompression of inbound streams should be enabled.
|
void |
setImmediateConnectTimeout(Duration immediateConnectTimeout)
If set to a positive duration instructs the client to connect to the gRPC endpoint when the GRPC stub is created.
|
void |
setKeepAliveTime(Duration keepAliveTime)
The default delay before we send a keepAlives.
|
void |
setKeepAliveTimeout(Duration keepAliveTimeout)
The default timeout for a keepAlives ping request.
|
void |
setKeepAliveWithoutCalls(Boolean keepAliveWithoutCalls)
Sets whether keepAlive will be performed when there are no outstanding RPC on a connection.
|
void |
setMaxInboundMessageSize(DataSize maxInboundMessageSize)
Sets the maximum message size in bytes allowed to be received by the channel.
|
void |
setNegotiationType(NegotiationType negotiationType)
Sets the negotiation type to use on the connection.
|
void |
setShutdownGracePeriod(Duration shutdownGracePeriod)
Sets the time to wait for the channel to gracefully shutdown (completing all requests).
|
String |
toString() |
public URI getAddress()
setAddress(String)
public void setAddress(URI address)
dns:/
.address
- The address to use for the channel or null to default to the fallback.setAddress(String)
public void setAddress(String address)
schema:[//[authority]][/path]
. If nothing is configured then the name of the client will be used along
with the default scheme. We recommend explicitly configuring the scheme used for the address resolutions such as
dns:/
.
Examples
static://localhost:9090
(refers to exactly one IPv4 or IPv6 address, dependent on the jre
configuration, it does not check whether there is actually someone listening on that network interface)static://10.0.0.10
static://10.0.0.10,10.11.12.11
static://10.0.0.10:9090,10.0.0.11:80,10.0.0.12:1234,[::1]:8080
dns:/localhost (might refer to the IPv4 or the IPv6 address or both, dependent on the system
configuration, it does not check whether there is actually someone listening on that network interface)
dns:/example.com
dns:/example.com:9090
dns:///example.com:9090
discovery:/foo-service
discovery:///foo-service
unix:<relative-path>
(Additional dependencies may be required)unix://</absolute-path>
(Additional dependencies may be required)address
- The string representation of an uri to use as target address or null to use a fallback.NameResolverProvider
public String getDefaultLoadBalancingPolicy()
ManagedChannelBuilder.defaultLoadBalancingPolicy(String)
public void setDefaultLoadBalancingPolicy(String defaultLoadBalancingPolicy)
LoadBalancerRegistry
. By
default this the round_robin
policy. Please note that this policy is different from the normal grpc-java
default policy pick_first
.defaultLoadBalancingPolicy
- The default load balancing policy to use or null to use the fallback.public boolean isEnableKeepAlive()
setEnableKeepAlive(Boolean)
public void setEnableKeepAlive(Boolean enableKeepAlive)
enableKeepAlive
- True, to enable. False, to disable. Null, to use the fallback.public Duration getKeepAliveTime()
setKeepAliveTime(Duration)
public void setKeepAliveTime(Duration keepAliveTime)
5min
. Default unit SECONDS
. Please note that shorter intervals increase the network burden for the server. Cannot be lower than
permitKeepAliveTime on server (default 5min).keepAliveTime
- The new default delay before sending keepAlives, or null to use the fallback.setEnableKeepAlive(Boolean)
,
NettyChannelBuilder.keepAliveTime(long, TimeUnit)
public Duration getKeepAliveTimeout()
setKeepAliveTimeout(Duration)
public void setKeepAliveTimeout(Duration keepAliveTimeout)
20s
. Default unit
SECONDS
.keepAliveTimeout
- The default timeout for a keepAlives ping request.setEnableKeepAlive(Boolean)
,
NettyChannelBuilder.keepAliveTimeout(long, TimeUnit)
public boolean isKeepAliveWithoutCalls()
setKeepAliveWithoutCalls(Boolean)
public void setKeepAliveWithoutCalls(Boolean keepAliveWithoutCalls)
false
.keepAliveWithoutCalls
- whether keepAlive will be performed when there are no outstanding RPC on a
connection.setEnableKeepAlive(Boolean)
,
NettyChannelBuilder.keepAliveWithoutCalls(boolean)
public Duration getShutdownGracePeriod()
0
the channel will force shutdown immediately. Defaults to 30s
.public void setShutdownGracePeriod(Duration shutdownGracePeriod)
0
the channel will force shutdown immediately. Defaults to
30s
.shutdownGracePeriod
- The time to wait for a graceful shutdown.public DataSize getMaxInboundMessageSize()
null
) then
gRPC's default
should be used. If set to -1
then it will use
the highest possible limit (not recommended).setMaxInboundMessageSize(DataSize)
public void setMaxInboundMessageSize(DataSize maxInboundMessageSize)
null
) then it
will default to gRPC's default
. If set to -1
then it will use
the highest possible limit (not recommended).maxInboundMessageSize
- The new maximum size in bytes allowed for incoming messages. -1
for max
possible. Null to use the gRPC's default.ManagedChannelBuilder.maxInboundMessageSize(int)
public boolean isFullStreamDecompression()
setFullStreamDecompression(Boolean)
public void setFullStreamDecompression(Boolean fullStreamDecompression)
fullStreamDecompression
- Whether full stream decompression should be enabled or null to use the fallback.ManagedChannelBuilder.enableFullStreamDecompression()
public NegotiationType getNegotiationType()
setNegotiationType(NegotiationType)
public void setNegotiationType(NegotiationType negotiationType)
TLS
(recommended),
PLAINTEXT_UPGRADE
or PLAINTEXT
.
Defaults to TLS.negotiationType
- The negotiation type to use or null to use the fallback.public Duration getImmediateConnectTimeout()
setImmediateConnectTimeout(Duration)
public void setImmediateConnectTimeout(Duration immediateConnectTimeout)
0
.immediateConnectTimeout
- Connection timeout at application startup.public GrpcChannelProperties.Security getSecurity()
public void copyDefaultsFrom(GrpcChannelProperties config)
config
- The config to copy the defaults from.protected boolean canEqual(Object other)