Top Description Inners Fields Constructors Methods
io.grpc

public final Class Grpc

extends Object
Class Inheritance
Imports
java.lang.annotation.Documented, .Retention, .RetentionPolicy, java.net.SocketAddress, .URI, .URISyntaxException, javax.net.ssl.SSLSession

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 and Inner Type Summary

Modifier and TypeClass and Description
public static @interface
Grpc.TransportAttr

Annotation for transport attributes.

Field Summary

Modifier and TypeField and Description
public static final Attributes.Key<SocketAddress>
TRANSPORT_ATTR_LOCAL_ADDR

Attribute key for the local address of a transport.

public static final Attributes.Key<SocketAddress>
TRANSPORT_ATTR_REMOTE_ADDR

Attribute key for the remote address of a transport.

public static final Attributes.Key<SSLSession>
TRANSPORT_ATTR_SSL_SESSION

Attribute key for SSL session of a transport.

Constructor Summary

AccessConstructor and Description
private
Grpc()

Method Summary

Modifier and TypeMethod and Description
private static String
authorityFromHostAndPort(String host, int port)

Combine a host and port into an authority string.

public static ManagedChannelBuilder<?>
newChannelBuilder(String target, ChannelCredentials creds)

Creates a channel builder with a target string and credentials.

public static ManagedChannelBuilder<?>
newChannelBuilderForAddress(String host, int port, ChannelCredentials creds)

Creates a channel builder from a host, port, and credentials.

public static ServerBuilder<?>
newServerBuilderForPort(int
the port to listen on
port
,
ServerCredentials
the server identity
creds
)

Static factory for creating a new ServerBuilder.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

TRANSPORT_ATTR_LOCAL_ADDRback to summary
public static final Attributes.Key<SocketAddress> TRANSPORT_ATTR_LOCAL_ADDR

Attribute key for the local address of a transport.

Annotations
@ExperimentalApi:https://github.com/grpc/grpc-java/issues/1710
@TransportAttr
TRANSPORT_ATTR_REMOTE_ADDRback to summary
public static final Attributes.Key<SocketAddress> TRANSPORT_ATTR_REMOTE_ADDR

Attribute key for the remote address of a transport.

Annotations
@ExperimentalApi:https://github.com/grpc/grpc-java/issues/1710
@TransportAttr
TRANSPORT_ATTR_SSL_SESSIONback to summary
public static final Attributes.Key<SSLSession> TRANSPORT_ATTR_SSL_SESSION

Attribute key for SSL session of a transport.

Annotations
@ExperimentalApi:https://github.com/grpc/grpc-java/issues/1710
@TransportAttr

Constructor Detail

Grpcback to summary
private Grpc()

Method Detail

authorityFromHostAndPortback to summary
private static String authorityFromHostAndPort(String host, int port)

Combine a host and port into an authority string.

newChannelBuilderback to summary
public static ManagedChannelBuilder<?> newChannelBuilder(String target, ChannelCredentials creds)

Creates a channel builder with a target string and credentials. The target can be either a valid NameResolver-compliant URI, or an authority string.

A NameResolver-compliant URI is an absolute hierarchical URI as defined by java.net.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"
newChannelBuilderForAddressback to summary
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 to newChannelBuilder(String, ChannelCredentials). IPv6 addresses are properly surrounded by square brackets ("[]").

newServerBuilderForPortback to summary
public static ServerBuilder<?> newServerBuilderForPort(int port, ServerCredentials creds)

Static factory for creating a new ServerBuilder.

Parameters
port:int

the port to listen on

creds:ServerCredentials

the server identity

io.grpc back to summary

public @Interface Grpc.TransportAttr

extends Annotation
Annotations
@ExperimentalApi:https://github.com/grpc/grpc-java/issues/4972
@Retention:SOURCE
@Documented

Annotation for transport attributes. It follows the annotation semantics defined by Attributes.

Method Summary

Inherited from java.lang.annotation.Annotation:
annotationTypeequalshashCodetoString