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.
  • Field Details

  • Method Details

    • 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 valid 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"
    • 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 to newChannelBuilder(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 on
      creds - the server identity