public final class Grpc extends Object
Modifier and Type | Class and Description |
---|---|
static interface |
Grpc.TransportAttr
Annotation for transport attributes.
|
Modifier and Type | Field and Description |
---|---|
static Attributes.Key<SocketAddress> |
TRANSPORT_ATTR_LOCAL_ADDR
Attribute key for the local address of a transport.
|
static Attributes.Key<SocketAddress> |
TRANSPORT_ATTR_REMOTE_ADDR
Attribute key for the remote address of a transport.
|
static Attributes.Key<SSLSession> |
TRANSPORT_ATTR_SSL_SESSION
Attribute key for SSL session of a transport.
|
Modifier and Type | Method and Description |
---|---|
static ManagedChannelBuilder<?> |
newChannelBuilder(String target,
ChannelCredentials creds)
Creates a channel builder with a target string and credentials.
|
static ManagedChannelBuilder<?> |
newChannelBuilderForAddress(String host,
int port,
ChannelCredentials creds)
Creates a channel builder from a host, port, and credentials.
|
static ServerBuilder<?> |
newServerBuilderForPort(int port,
ServerCredentials creds)
Static factory for creating a new ServerBuilder.
|
@ExperimentalApi(value="https://github.com/grpc/grpc-java/issues/1710") @Grpc.TransportAttr public static final Attributes.Key<SocketAddress> TRANSPORT_ATTR_REMOTE_ADDR
@ExperimentalApi(value="https://github.com/grpc/grpc-java/issues/1710") @Grpc.TransportAttr public static final Attributes.Key<SocketAddress> TRANSPORT_ATTR_LOCAL_ADDR
@ExperimentalApi(value="https://github.com/grpc/grpc-java/issues/1710") @Grpc.TransportAttr public static final Attributes.Key<SSLSession> TRANSPORT_ATTR_SSL_SESSION
public static ManagedChannelBuilder<?> newChannelBuilder(String target, ChannelCredentials creds)
NameResolver
-compliant URI, or an authority string.
A NameResolver
-compliant URI is an absolute hierarchical URI as defined by URI
. Example URIs:
"dns:///foo.googleapis.com:8080"
"dns:///foo.googleapis.com"
"dns:///%5B2001:db8:85a3:8d3:1319:8a2e:370:7348%5D:443"
"dns://8.8.8.8/foo.googleapis.com:8080"
"dns://8.8.8.8/foo.googleapis.com"
"zookeeper://zk.example.com:9900/example_service"
An authority string will be converted to a NameResolver
-compliant URI, which has
the scheme from the name resolver with the highest priority (e.g. "dns"
),
no authority, and the original authority string as its path after properly escaped.
We recommend libraries to specify the schema explicitly if it is known, since libraries cannot
know which NameResolver will be default during runtime.
Example authority strings:
"localhost"
"127.0.0.1"
"localhost:8080"
"foo.googleapis.com:8080"
"127.0.0.1:8080"
"[2001:db8:85a3:8d3:1319:8a2e:370:7348]"
"[2001:db8:85a3:8d3:1319:8a2e:370:7348]:443"
public static ManagedChannelBuilder<?> newChannelBuilderForAddress(String host, int port, ChannelCredentials creds)
newChannelBuilder(String,
ChannelCredentials)
. IPv6 addresses are properly surrounded by square brackets ("[]").public static ServerBuilder<?> newServerBuilderForPort(int port, ServerCredentials creds)
port
- the port to listen oncreds
- the server identity