Package io.grpc
Class Grpc
- java.lang.Object
-
- io.grpc.Grpc
-
public final class Grpc extends Object
Stuff that are part of the public API but are not bound to particular classes, e.g., static methods, constants, attribute and context keys.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
Grpc.TransportAttr
Annotation for transport attributes.
-
Field Summary
Fields Modifier and Type Field 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.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method 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.
-
-
-
Field Detail
-
TRANSPORT_ATTR_REMOTE_ADDR
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/1710") @TransportAttr public static final Attributes.Key<SocketAddress> TRANSPORT_ATTR_REMOTE_ADDR
Attribute key for the remote address of a transport.
-
TRANSPORT_ATTR_LOCAL_ADDR
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/1710") @TransportAttr public static final Attributes.Key<SocketAddress> TRANSPORT_ATTR_LOCAL_ADDR
Attribute key for the local address of a transport.
-
TRANSPORT_ATTR_SSL_SESSION
@ExperimentalApi("https://github.com/grpc/grpc-java/issues/1710") @TransportAttr public static final Attributes.Key<SSLSession> TRANSPORT_ATTR_SSL_SESSION
Attribute key for SSL session of a transport.
-
-
Method Detail
-
newChannelBuilder
public static ManagedChannelBuilder<?> newChannelBuilder(String target, ChannelCredentials creds)
Creates a channel builder with a target string and credentials. The target can be either a validNameResolver
-compliant URI, or an authority string.A
NameResolver
-compliant URI is an absolute hierarchical URI as defined byURI
. 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"
-
newChannelBuilderForAddress
public static ManagedChannelBuilder<?> newChannelBuilderForAddress(String host, int port, ChannelCredentials creds)
Creates a channel builder from a host, port, and credentials. The host and port are combined to form an authority string and then passed tonewChannelBuilder(String, ChannelCredentials)
. IPv6 addresses are properly surrounded by square brackets ("[]").
-
newServerBuilderForPort
public static ServerBuilder<?> newServerBuilderForPort(int port, ServerCredentials creds)
Static factory for creating a new ServerBuilder.- Parameters:
port
- the port to listen oncreds
- the server identity
-
-