Top Description Inners Constructors Methods
io.grpc

public abstract Class ManagedChannelProvider

extends Object
Class Inheritance
Annotations
@Internal
Imports
com.google.common.base.Preconditions, java.net.SocketAddress, java.util.Collection

Provider of managed channels for transport agnostic consumption.

Implementations can be automatically discovered by gRPC via Java's SPI mechanism. For automatic discovery, the implementation must have a zero-argument constructor and include a resource named META-INF/services/io.grpc.ManagedChannelProvider in their JAR. The file's contents should be the implementation's class name.

Implementations should not throw. If they do, it may interrupt class loading. If exceptions may reasonably occur for implementation-specific reasons, implementations should generally handle the exception gracefully and return false from isAvailable().

Nested and Inner Type Summary

Modifier and TypeClass and Description
public static class
public static class
ManagedChannelProvider.ProviderNotFoundException

Thrown when no suitable ManagedChannelProvider objects can be found.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected abstract ManagedChannelBuilder<?>
builderForAddress(String name, int port)

Creates a new builder with the given host and port.

protected abstract ManagedChannelBuilder<?>
builderForTarget(String target)

Creates a new builder with the given target URI.

protected abstract Collection<Class<? extends SocketAddress>>
getSupportedSocketAddressTypes()

Returns the SocketAddress types this ManagedChannelProvider supports.

protected abstract boolean
isAvailable()

Whether this provider is available for use, taking the current environment into consideration.

protected ManagedChannelProvider.NewChannelBuilderResult
newChannelBuilder(String target, ChannelCredentials creds)

Creates a new builder with the given target URI and credentials.

protected abstract int
priority()

A priority, from 0 to 10 that this provider should be used, taking the current environment into consideration.

public static ManagedChannelProvider
provider()

Returns the ClassLoader-wide default channel.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Constructor Detail

ManagedChannelProviderback to summary
public ManagedChannelProvider()

Method Detail

builderForAddressback to summary
protected abstract ManagedChannelBuilder<?> builderForAddress(String name, int port)

Creates a new builder with the given host and port.

builderForTargetback to summary
protected abstract ManagedChannelBuilder<?> builderForTarget(String target)

Creates a new builder with the given target URI.

getSupportedSocketAddressTypesback to summary
protected abstract Collection<Class<? extends SocketAddress>> getSupportedSocketAddressTypes()

Returns the SocketAddress types this ManagedChannelProvider supports.

isAvailableback to summary
protected abstract boolean isAvailable()

Whether this provider is available for use, taking the current environment into consideration. If false, no other methods are safe to be called.

newChannelBuilderback to summary
protected ManagedChannelProvider.NewChannelBuilderResult newChannelBuilder(String target, ChannelCredentials creds)

Creates a new builder with the given target URI and credentials. Returns an error-string result if unable to understand the credentials.

priorityback to summary
protected abstract int priority()

A priority, from 0 to 10 that this provider should be used, taking the current environment into consideration. 5 should be considered the default, and then tweaked based on environment detection. A priority of 0 does not imply that the provider wouldn't work; just that it should be last in line.

providerback to summary
public static ManagedChannelProvider provider()

Returns the ClassLoader-wide default channel.

Exceptions
ProviderNotFoundException:
if no provider is available
io.grpc back to summary

public final Class ManagedChannelProvider.NewChannelBuilderResult

extends Object
Class Inheritance

Field Summary

Modifier and TypeField and Description
private final ManagedChannelBuilder<?>
private final String

Constructor Summary

AccessConstructor and Description
private

Method Summary

Modifier and TypeMethod and Description
public static ManagedChannelProvider.NewChannelBuilderResult
public static ManagedChannelProvider.NewChannelBuilderResult
error(String error)

public ManagedChannelBuilder<?>
public String
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

channelBuilderback to summary
private final ManagedChannelBuilder<?> channelBuilder
errorback to summary
private final String error

Constructor Detail

NewChannelBuilderResultback to summary
private NewChannelBuilderResult(ManagedChannelBuilder<?> channelBuilder, String error)

Method Detail

channelBuilderback to summary
public static ManagedChannelProvider.NewChannelBuilderResult channelBuilder(ManagedChannelBuilder<?> builder)
errorback to summary
public static ManagedChannelProvider.NewChannelBuilderResult error(String error)
getChannelBuilderback to summary
public ManagedChannelBuilder<?> getChannelBuilder()
getErrorback to summary
public String getError()
io.grpc back to summary

public final Class ManagedChannelProvider.ProviderNotFoundException

extends RuntimeException
Class Inheritance

Thrown when no suitable ManagedChannelProvider objects can be found.

Field Summary

Modifier and TypeField and Description
private static final long

Constructor Summary

AccessConstructor and Description
public

Field Detail

serialVersionUIDback to summary
private static final long serialVersionUID

Hides java.lang.RuntimeException.serialVersionUID.

Constructor Detail

ProviderNotFoundExceptionback to summary
public ProviderNotFoundException(String msg)