Package org.kiwiproject.beta.net
Class KiwiInternetAddresses2
- java.lang.Object
-
- org.kiwiproject.beta.net.KiwiInternetAddresses2
-
@Beta public final class KiwiInternetAddresses2 extends Object
Utilities related to internet addresses.These utilities could be considered for kiwi's
KiwiInternetAddressesclass.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classKiwiInternetAddresses2.SimpleAddressHolder
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static KiwiInternetAddresses2.SimpleAddressHolderresolveLocalAddressPreferringSupplied(Supplier<String> hostnameSupplier, Supplier<String> ipSupplier)Return aKiwiInternetAddresses2.SimpleAddressHoldercontaining a hostname and IP supplied by the given Suppliers, or falling back to the hostname and address returned byInetAddress.getLocalHost()when a Supplier returns a blank String (null, empty string, whitespace only).
-
-
-
Method Detail
-
resolveLocalAddressPreferringSupplied
public static KiwiInternetAddresses2.SimpleAddressHolder resolveLocalAddressPreferringSupplied(Supplier<String> hostnameSupplier, Supplier<String> ipSupplier)
Return aKiwiInternetAddresses2.SimpleAddressHoldercontaining a hostname and IP supplied by the given Suppliers, or falling back to the hostname and address returned byInetAddress.getLocalHost()when a Supplier returns a blank String (null, empty string, whitespace only).The primary use case for this is when you might want to override the default hostname and/or IP using some external configuration such as environment variables or system properties specified via command line. The suppliers can do something like:
() -> environment.getenv("CUSTOM_HOST")).- Parameters:
hostnameSupplier- supplier of hostname, may return blank stringipSupplier- supplier of ip address, may return blank string- Returns:
- a new SimpleAddressHolder instance
- Implementation Note:
- This is a pretty narrow use case, so it most likely won't ever move into kiwi proper. The one place we actually use this is in a "core service" library which does a bunch of setup and initialization common across services. One of the specific things it does is to get the hostname and IP address to use when registering a service, e.g. to Consul. We permit specific overrides to the hostname and/or IP address via environment variables in a service host.
-
-