Interface EurekaDiscovery
- All Superinterfaces:
AutoCloseable,Discovery,RuntimeType.Api<EurekaDiscoveryConfig>
Discovery implementation that communicates with Netflix's Eureka server version 2.
Please see the Discovery documentation for important contractual obligations that must be fulfilled by any
implementation of this interface.
Configuration
Configuration for EurekaDiscoveryConfig instances is normally found under the top-level Helidon
configuration key named discovery, under a sub-key named eureka. Please see the configuration
reference for more details.
Configuration for connecting to a Eureka server hosted on localhost, port 8761 (the port used by
Eureka by default), looks like this (in YAML format, often in an application.yaml classpath resource):
discovery:
eureka:
client:
base-uri: "http://localhost:8761/eureka"
enabled: true # true by default; made explicit here for example purposes
Acquisition ("Declarative" Usage)
To acquire a Discovery instance, inject it, using the Service.Inject annotation. Alternatively, use the static Services.get(Class) method, supplying Discovery.class as its
sole argument.
Creation ("Imperative" Usage)
Users of the Helidon Builder API may create
instances of this interface via the create(EurekaDiscoveryConfig) method. Instances created in this manner
are guaranteed to implement all of the contractual requirements of this interface and its (transitive)
supertypes.
(Users of the Helidon Builder API may
indirectly create instances of the EurekaDiscoveryConfig interface, if required, via the builder()
method, which is a Helidon Builder API-mandated convenience method that, by specification, simply delegates to the
EurekaDiscoveryConfig.builder() method. See EurekaDiscoveryConfig.builder() for contractual details
related to the creation of EurekaDiscoveryConfig.Builder instances. See EurekaDiscoveryConfig for
contractual details related to EurekaDiscoveryConfig instances built using EurekaDiscoveryConfig.Builder instances. These contracts
do not affect the requirements this interface imposes on its implementations.)
Any other means of implementing this interface is permitted, so long as it results in an implementation that implements the contractual requirements of this interface's (transitive and reflexive) supertypes.
Logging
Implementations created via the create(EurekaDiscoveryConfig) method (which includes instances available
via dependency injection), and any
internal supporting classes, will use Loggers whose names
begin with io.helidon.discovery.providers.eureka..
Logging output is particularly important to monitor because as a general rule Discovery implementations
must strive to be resilient in the presence of failures.
Design note: This interface extends Api<EurekaDiscoveryConfig> to conform to
the requirements of the Helidon Builder
API. Implementations of this interface must therefore also abide by its contract.
- See Also:
-
Method Summary
Modifier and TypeMethodDescriptionbuilder()A convenience method required by, and complying with the requirements of, the Helidon Builder API that, per contract, invokes theEurekaDiscoveryConfig.builder()method and returns its result.voidclose()Closes any resources used by thisEurekaDiscoveryimplementation.static EurekaDiscoverycreate(EurekaDiscoveryConfig prototype) Required by, and complying with the requirements of, the Helidon Builder API, creates a newEurekaDiscoveryimplementation whose state is derived from the suppliedEurekaDiscoveryConfigand returns it.static EurekaDiscoverycreate(Consumer<EurekaDiscoveryConfig.Builder> consumer) A convenience method required by, and complying with the requirements of, the Helidon Builder API that, per contract, builds a newEurekaDiscoveryimplementation and returns it.Returns a non-null, determinateEurekaDiscoveryConfigobject representing the prototypical state of thisEurekaDiscoveryimplementation.Returns a non-null, immutable, non-empty,SequencedSetofDiscoveredUriinstances suitable for the supplied discovery name.
-
Method Details
-
close
void close()Closes any resources used by thisEurekaDiscoveryimplementation.Eureka is a server. Its existence implies network communication. Consequently
EurekaDiscoveryimplementations are required to implement this method, as appropriate, such that it cleans up network-related resources (such as HTTP connections).The behavior of any given
EurekaDiscoveryimplementation is undefined, unless otherwise documented by the specific implementation, after an invocation of itsclose()method has taken place. For maximum portability, callers should assume that closing aEurekaDiscoveryinstance transitions it into a terminal state.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceDiscovery- Throws:
RuntimeException- if an error occurs- See Also:
-
prototype
EurekaDiscoveryConfig prototype()Returns a non-null, determinateEurekaDiscoveryConfigobject representing the prototypical state of thisEurekaDiscoveryimplementation.- Specified by:
prototypein interfaceRuntimeType.Api<EurekaDiscoveryConfig>- Returns:
- a non-
null, determinateEurekaDiscoveryConfigobject representing the prototypical state of thisEurekaDiscoveryimplementation - See Also:
-
uris
Returns a non-null, immutable, non-empty,SequencedSetofDiscoveredUriinstances suitable for the supplied discovery name.See the documentation for the
Discovery.uris(String, URI)method for more contractual information. Documentation that follows is specific to allEurekaDiscoveryimplementations. Any givenEurekaDiscoveryimplementation may further refine these requirements.Implementations of this method often serve cached information. The cache is typically refreshed by a background thread on a regular interval. See
EurekaDiscoveryConfig.cache()andEurekaDiscoveryConfig.registryFetchInterval()and their related methods.Implementations of this method must treat discovery names in a case-insensitive manner.
Implementations of this method must order elements in the returned
SequencedSetwith elements that are known at invocation time to beUPorSTARTINGpreceding other elements. All other ordering is undefined.- Specified by:
urisin interfaceDiscovery- Parameters:
discoveryName- a discovery name; must not benull; will be handled in a case-insensitive manner; must comply with any requirements that might exist pertaining to a Eureka application namedefaultValue- aURIthat will be represented as aDiscoveredUriwith no metdata if any kind of error occurs that prevents a normal invocation, or if the return value of an invocation of this method would otherwise be empty; must not benull; will always be represented as aDiscoveredUriand included as the last element in the returnedSequencedSet- Returns:
- a non-
null, immutable, non-empty,SequencedSetofDiscoveredUriinstances - Throws:
NullPointerException- if any argument isnullIllegalArgumentException- if any argument is unsuitable in any way- See Also:
-
builder
A convenience method required by, and complying with the requirements of, the Helidon Builder API that, per contract, invokes theEurekaDiscoveryConfig.builder()method and returns its result.- Returns:
- a non-
nullEurekaDiscoveryConfig.BuilderofEurekaDiscoveryConfiginstances - See Also:
-
create
Required by, and complying with the requirements of, the Helidon Builder API, creates a newEurekaDiscoveryimplementation whose state is derived from the suppliedEurekaDiscoveryConfigand returns it.- Parameters:
prototype- theEurekaDiscoveryConfigfrom which the implementation will be created; must not benull- Returns:
- a new, non-
nullEurekaDiscoveryimplementation - Throws:
NullPointerException- ifprototypeisnull- See Also:
-
create
A convenience method required by, and complying with the requirements of, the Helidon Builder API that, per contract, builds a newEurekaDiscoveryimplementation and returns it.- Parameters:
consumer- aConsumerofEurekaDiscoveryConfig.Builderinstances that typically mutates its suppliedEurekaDiscoveryConfig.Builder; must not benull- Returns:
- a new, non-
nullEurekaDiscoveryimplementation as returned by theEurekaDiscoveryConfig.Builder.build()method - Throws:
NullPointerException- ifconsumerisnull- See Also:
-