Class GrpcUtils
java.lang.Object
org.springframework.grpc.internal.GrpcUtils
Provides convenience methods for various gRPC functions.
NOTE: Even though this class visibility is `public` it is intended for internal use only and not recommended for direct use.
- Author:
- David Syer, Chris Bono
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final StringServer should listen to any IPv4 and IPv6 address.static final intDefault port to use. -
Method Summary
Modifier and TypeMethodDescriptionstatic @Nullable StringgetHostName(String address) Gets the hostname given an address.static intGets the port given an address.
-
Field Details
-
ANY_IP_ADDRESS
Server should listen to any IPv4 and IPv6 address.- See Also:
-
DEFAULT_PORT
public static final int DEFAULT_PORTDefault port to use.- See Also:
-
-
Method Details
-
getPort
Gets the port given an address.The address is expected to conform to the requirements of the input address for
URI(String)with the following exceptions:- do not include a scheme
- wildcard '*' host is acceptable
- Parameters:
address- the server address as described above- Returns:
- the port extracted from the address or
DEFAULT_PORTif port was not specified or was invalid (e.g. 'localhost:xxx') - Throws:
IllegalArgumentException- if the address represents a unix domain socket (i.e. starts with 'unix:') or includes a scheme orURI(String)is unable to parse the address
-
getHostName
Gets the hostname given an address.The address is expected to conform to the requirements of the input address for
URI(String)with the following exceptions:- do not include a scheme
- wildcard '*' host is acceptable
- Parameters:
address- the server address as described above- Returns:
- the hostname extracted from the address or null if no hostname could be extracted
- Throws:
IllegalArgumentException- if the address represents a unix domain socket (i.e. starts with 'unix:') or includes a scheme orURI(String)is unable to parse the address
-