Package io.nitric.util
Class GrpcChannelProvider
- java.lang.Object
-
- io.nitric.util.GrpcChannelProvider
-
public class GrpcChannelProvider extends Object
Provides a gRPC Managed Channel object by use by Nitric Service Clients.
The default host and port values are '127.0.0.1' and 50051 respectively. To change these default values set the respective Environment Variables:
NITRIC_SERVICE_HOST
andNITRIC_SERVICE_PORT
.
-
-
Field Summary
Fields Modifier and Type Field Description protected static io.grpc.ManagedChannel
channel
protected static String
NITRIC_SERVICE_HOST_DEFAULT
protected static String
NITRIC_SERVICE_HOST_ENV_VAR_NAME
protected static String
NITRIC_SERVICE_PORT_DEFAULT
protected static String
NITRIC_SERVICE_PORT_ENV_VAR_NAME
-
Constructor Summary
Constructors Constructor Description GrpcChannelProvider()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description static io.grpc.ManagedChannel
getChannel()
protected static String
getEnvVar(String varName, String defaultValue)
Return the environment variable value if defined or the default value otherwise.String
toString()
-
-
-
Field Detail
-
NITRIC_SERVICE_HOST_DEFAULT
protected static final String NITRIC_SERVICE_HOST_DEFAULT
- See Also:
- Constant Field Values
-
NITRIC_SERVICE_PORT_DEFAULT
protected static final String NITRIC_SERVICE_PORT_DEFAULT
- See Also:
- Constant Field Values
-
NITRIC_SERVICE_HOST_ENV_VAR_NAME
protected static final String NITRIC_SERVICE_HOST_ENV_VAR_NAME
- See Also:
- Constant Field Values
-
NITRIC_SERVICE_PORT_ENV_VAR_NAME
protected static final String NITRIC_SERVICE_PORT_ENV_VAR_NAME
- See Also:
- Constant Field Values
-
channel
protected static io.grpc.ManagedChannel channel
-
-
Method Detail
-
getChannel
public static io.grpc.ManagedChannel getChannel()
- Returns:
- the Nitric gRPC Managed Channel.
-
toString
public String toString()
-
getEnvVar
protected static String getEnvVar(String varName, String defaultValue)
Return the environment variable value if defined or the default value otherwise.- Parameters:
varName
- the environmental variable name (required)defaultValue
- the default fallback value (required)- Returns:
- the environment variable value or default if not defined
-
-