- java.lang.Object
-
- io.helidon.grpc.client.GrpcChannelsProvider
-
public class GrpcChannelsProvider extends Object
GrpcChannelsProvider is a factory for pre-configured gRPC Channel instances.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classGrpcChannelsProvider.BuilderBuilder builds an instance ofGrpcChannelsProvider.
-
Field Summary
Fields Modifier and Type Field Description static StringCFG_KEY_CHANNELSThe configuration key for the channels configuration.static StringDEFAULT_CHANNEL_NAMEA constant for holding the default channel configuration name (which is "default").static StringDEFAULT_HOSTA constant for holding the default host name (which is "localhost").static intDEFAULT_PORTA constant for holding the default port (which is "1408").
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static GrpcChannelsProvider.Builderbuilder()Create a newGrpcChannelsProvider.Builder.static GrpcChannelsProvider.Builderbuilder(Config config)Create a newGrpcChannelsProvider.Builder.io.grpc.ManagedChannelchannel(String name)Returns aManagedChannelfor the specified channel or host name.static GrpcChannelsProvidercreate()Builds a new instance ofGrpcChannelsProviderusing default configuration.static GrpcChannelsProvidercreate(Config config)Creates aGrpcChannelsProviderusing the specified configuration.
-
-
-
Field Detail
-
DEFAULT_CHANNEL_NAME
public static final String DEFAULT_CHANNEL_NAME
A constant for holding the default channel configuration name (which is "default").- See Also:
- Constant Field Values
-
DEFAULT_HOST
public static final String DEFAULT_HOST
A constant for holding the default host name (which is "localhost").- See Also:
- Constant Field Values
-
CFG_KEY_CHANNELS
public static final String CFG_KEY_CHANNELS
The configuration key for the channels configuration.- See Also:
- Constant Field Values
-
DEFAULT_PORT
public static final int DEFAULT_PORT
A constant for holding the default port (which is "1408").- See Also:
- Constant Field Values
-
-
Method Detail
-
create
public static GrpcChannelsProvider create()
Builds a new instance ofGrpcChannelsProviderusing default configuration. The default configuration connects to "localhost:1408" without TLS.- Returns:
- a new instance of
GrpcChannelsProvider
-
create
public static GrpcChannelsProvider create(Config config)
Creates aGrpcChannelsProviderusing the specified configuration.- Parameters:
config- The externalized configuration.- Returns:
- a new instance of
GrpcChannelsProvider
-
builder
public static GrpcChannelsProvider.Builder builder()
Create a newGrpcChannelsProvider.Builder.- Returns:
- a new
GrpcChannelsProvider.Builder
-
builder
public static GrpcChannelsProvider.Builder builder(Config config)
Create a newGrpcChannelsProvider.Builder.- Parameters:
config- theConfigto bootstrap from- Returns:
- a new
GrpcChannelsProvider.Builder
-
channel
public io.grpc.ManagedChannel channel(String name)
Returns aManagedChannelfor the specified channel or host name.If the specified channel name does not exist in the configuration, we will assume that it represents the name of the gRPC host to connect to and will create a plain text channel to the host with the specified
name, on a default port (1408).- Parameters:
name- the name of the channel configuration as specified in the configuration file, or the name of the host to connect to- Returns:
- a new instance of
ManagedChannel - Throws:
NullPointerException- if name is nullIllegalArgumentException- if name is empty
-
-