public final class AndroidChannelBuilder extends io.grpc.ForwardingChannelBuilder<AndroidChannelBuilder>
ManagedChannel
that, when provided with a Context
, will automatically
monitor the Android device's network state to smoothly handle intermittent network failures.
Currently only compatible with gRPC's OkHttp transport, which must be available at runtime.
Requires the Android ACCESS_NETWORK_STATE permission.
Modifier and Type | Method and Description |
---|---|
io.grpc.ManagedChannel |
build()
Builds a channel with current configurations.
|
AndroidChannelBuilder |
context(android.content.Context context)
Enables automatic monitoring of the device's network state.
|
protected io.grpc.ManagedChannelBuilder<?> |
delegate() |
static AndroidChannelBuilder |
forAddress(java.lang.String name,
int port)
Creates a new builder with the given host and port.
|
static AndroidChannelBuilder |
forTarget(java.lang.String target)
Creates a new builder with the given target string that will be resolved by
NameResolver . |
static AndroidChannelBuilder |
fromBuilder(io.grpc.ManagedChannelBuilder<?> builder)
Deprecated.
Use
usingBuilder(ManagedChannelBuilder) instead. |
static AndroidChannelBuilder |
usingBuilder(io.grpc.ManagedChannelBuilder<?> builder)
Creates a new builder, which delegates to the given ManagedChannelBuilder.
|
compressorRegistry, decompressorRegistry, defaultLoadBalancingPolicy, defaultServiceConfig, directExecutor, disableRetry, disableServiceConfigLookUp, enableFullStreamDecompression, enableRetry, executor, idleTimeout, intercept, intercept, keepAliveTime, keepAliveTimeout, keepAliveWithoutCalls, maxHedgedAttempts, maxInboundMessageSize, maxInboundMetadataSize, maxRetryAttempts, maxTraceEvents, nameResolverFactory, offloadExecutor, overrideAuthority, perRpcBufferLimit, proxyDetector, retryBufferSize, setBinaryLog, thisT, toString, usePlaintext, userAgent, useTransportSecurity
public static AndroidChannelBuilder forTarget(java.lang.String target)
NameResolver
.public static AndroidChannelBuilder forAddress(java.lang.String name, int port)
@ExperimentalApi(value="https://github.com/grpc/grpc-java/issues/6043") @Deprecated public static AndroidChannelBuilder fromBuilder(io.grpc.ManagedChannelBuilder<?> builder)
usingBuilder(ManagedChannelBuilder)
instead.public static AndroidChannelBuilder usingBuilder(io.grpc.ManagedChannelBuilder<?> builder)
The provided builder
becomes "owned" by AndroidChannelBuilder. The caller should
not modify the provided builder and AndroidChannelBuilder may modify it. That implies reusing
the provided builder to build another channel may result with unexpected configurations. That
usage should be discouraged.
public AndroidChannelBuilder context(android.content.Context context)
protected io.grpc.ManagedChannelBuilder<?> delegate()
delegate
in class io.grpc.ForwardingChannelBuilder<AndroidChannelBuilder>
public io.grpc.ManagedChannel build()
build
in class io.grpc.ForwardingChannelBuilder<AndroidChannelBuilder>