@ExperimentalApi(value="https://github.com/grpc/grpc-java/issues/1785") public class OkHttpChannelBuilder extends io.grpc.internal.AbstractManagedChannelImplBuilder<OkHttpChannelBuilder>
Modifier and Type | Field and Description |
---|---|
static ConnectionSpec |
DEFAULT_CONNECTION_SPEC |
Modifier | Constructor and Description |
---|---|
protected |
OkHttpChannelBuilder(String host,
int port) |
Modifier and Type | Method and Description |
---|---|
protected io.grpc.internal.ClientTransportFactory |
buildTransportFactory() |
OkHttpChannelBuilder |
connectionSpec(ConnectionSpec connectionSpec)
For secure connection, provides a ConnectionSpec to specify Cipher suite and
TLS versions.
|
OkHttpChannelBuilder |
enableKeepAlive(boolean enable)
Enable keepalive with default delay and timeout.
|
OkHttpChannelBuilder |
enableKeepAlive(boolean enable,
long keepAliveDelay,
TimeUnit delayUnit,
long keepAliveTimeout,
TimeUnit timeoutUnit)
Enable keepalive with custom delay and timeout.
|
static OkHttpChannelBuilder |
forAddress(String host,
int port)
Creates a new builder for the given server host and port.
|
static OkHttpChannelBuilder |
forTarget(String target)
Creates a new builder for the given target that will be resolved by
NameResolver . |
protected Attributes |
getNameResolverParams() |
OkHttpChannelBuilder |
negotiationType(NegotiationType type)
Sets the negotiation type for the HTTP/2 connection.
|
OkHttpChannelBuilder |
sslSocketFactory(SSLSocketFactory factory)
Override the default
SSLSocketFactory and enable NegotiationType.TLS
negotiation. |
OkHttpChannelBuilder |
transportExecutor(Executor transportExecutor)
Override the default executor necessary for internal transport use.
|
OkHttpChannelBuilder |
usePlaintext(boolean skipNegotiation)
Equivalent to using
negotiationType(NegotiationType) with PLAINTEXT . |
build, checkAuthority, compressorRegistry, decompressorRegistry, directExecutor, executor, idleTimeout, intercept, intercept, loadBalancerFactory, loadBalancerFactory, maxInboundMessageSize, maxInboundMessageSize, nameResolverFactory, overrideAuthority, statsContextFactory, userAgent
public static final ConnectionSpec DEFAULT_CONNECTION_SPEC
protected OkHttpChannelBuilder(String host, int port)
public static OkHttpChannelBuilder forAddress(String host, int port)
public static OkHttpChannelBuilder forTarget(String target)
NameResolver
.public final OkHttpChannelBuilder transportExecutor(@Nullable Executor transportExecutor)
The channel does not take ownership of the given executor. It is the caller' responsibility to shutdown the executor when appropriate.
public final OkHttpChannelBuilder negotiationType(NegotiationType type)
If TLS is enabled a default SSLSocketFactory
is created using the best
Provider
available and is NOT based on
SSLSocketFactory.getDefault()
. To more precisely control the TLS configuration call
sslSocketFactory
to override the socket factory used.
Default: TLS
public final OkHttpChannelBuilder enableKeepAlive(boolean enable)
public final OkHttpChannelBuilder enableKeepAlive(boolean enable, long keepAliveDelay, TimeUnit delayUnit, long keepAliveTimeout, TimeUnit timeoutUnit)
public final OkHttpChannelBuilder sslSocketFactory(SSLSocketFactory factory)
SSLSocketFactory
and enable NegotiationType.TLS
negotiation.
By default, when TLS is enabled, SSLSocketFactory.getDefault()
will be used.
NegotiationType.TLS
will be applied by calling this method.
public final OkHttpChannelBuilder connectionSpec(ConnectionSpec connectionSpec)
By default DEFAULT_CONNECTION_SPEC
will be used.
This method is only used when building a secure connection. For plaintext
connection, use usePlaintext(boolean)
instead.
IllegalArgumentException
- If connectionSpec
is not with TLSpublic final OkHttpChannelBuilder usePlaintext(boolean skipNegotiation)
negotiationType(NegotiationType)
with PLAINTEXT
.usePlaintext
in class ManagedChannelBuilder<OkHttpChannelBuilder>
protected final io.grpc.internal.ClientTransportFactory buildTransportFactory()
buildTransportFactory
in class io.grpc.internal.AbstractManagedChannelImplBuilder<OkHttpChannelBuilder>
protected Attributes getNameResolverParams()
getNameResolverParams
in class io.grpc.internal.AbstractManagedChannelImplBuilder<OkHttpChannelBuilder>