- 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 class
GrpcChannelsProvider.Builder
Builder builds an instance ofGrpcChannelsProvider
.
-
Field Summary
Fields Modifier and Type Field Description static String
CFG_KEY_CHANNELS
The configuration key for the channels configuration.static String
DEFAULT_CHANNEL_NAME
A constant for holding the default channel configuration name (which is "default").static String
DEFAULT_HOST
A constant for holding the default host name (which is "localhost").static int
DEFAULT_PORT
A 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.Builder
builder()
Create a newGrpcChannelsProvider.Builder
.static GrpcChannelsProvider.Builder
builder(Config config)
Create a newGrpcChannelsProvider.Builder
.io.grpc.ManagedChannel
channel(String name)
Returns aManagedChannel
for the specified channel or host name.static GrpcChannelsProvider
create()
Builds a new instance ofGrpcChannelsProvider
using default configuration.static GrpcChannelsProvider
create(Config config)
Creates aGrpcChannelsProvider
using 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 ofGrpcChannelsProvider
using 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 aGrpcChannelsProvider
using 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
- theConfig
to bootstrap from- Returns:
- a new
GrpcChannelsProvider.Builder
-
channel
public io.grpc.ManagedChannel channel(String name)
Returns aManagedChannel
for 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
-
-