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 Logger
s 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.void
close()
Closes any resources used by thisEurekaDiscovery
implementation.static EurekaDiscovery
create
(EurekaDiscoveryConfig prototype) Required by, and complying with the requirements of, the Helidon Builder API, creates a newEurekaDiscovery
implementation whose state is derived from the suppliedEurekaDiscoveryConfig
and returns it.static EurekaDiscovery
create
(Consumer<EurekaDiscoveryConfig.Builder> consumer) A convenience method required by, and complying with the requirements of, the Helidon Builder API that, per contract, builds a newEurekaDiscovery
implementation and returns it.Returns a non-null
, determinateEurekaDiscoveryConfig
object representing the prototypical state of thisEurekaDiscovery
implementation.Returns a non-null
, immutable, non-empty,SequencedSet
ofDiscoveredUri
instances suitable for the supplied discovery name.
-
Method Details
-
close
void close()Closes any resources used by thisEurekaDiscovery
implementation.Eureka is a server. Its existence implies network communication. Consequently
EurekaDiscovery
implementations 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
EurekaDiscovery
implementation 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 aEurekaDiscovery
instance transitions it into a terminal state.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceDiscovery
- Throws:
RuntimeException
- if an error occurs- See Also:
-
prototype
EurekaDiscoveryConfig prototype()Returns a non-null
, determinateEurekaDiscoveryConfig
object representing the prototypical state of thisEurekaDiscovery
implementation.- Specified by:
prototype
in interfaceRuntimeType.Api<EurekaDiscoveryConfig>
- Returns:
- a non-
null
, determinateEurekaDiscoveryConfig
object representing the prototypical state of thisEurekaDiscovery
implementation - See Also:
-
uris
Returns a non-null
, immutable, non-empty,SequencedSet
ofDiscoveredUri
instances 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 allEurekaDiscovery
implementations. Any givenEurekaDiscovery
implementation 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
SequencedSet
with elements that are known at invocation time to beUP
orSTARTING
preceding other elements. All other ordering is undefined.- Specified by:
uris
in 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
- aURI
that will be represented as aDiscoveredUri
with 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 aDiscoveredUri
and included as the last element in the returnedSequencedSet
- Returns:
- a non-
null
, immutable, non-empty,SequencedSet
ofDiscoveredUri
instances - Throws:
NullPointerException
- if any argument isnull
IllegalArgumentException
- 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-
null
EurekaDiscoveryConfig.Builder
ofEurekaDiscoveryConfig
instances - See Also:
-
create
Required by, and complying with the requirements of, the Helidon Builder API, creates a newEurekaDiscovery
implementation whose state is derived from the suppliedEurekaDiscoveryConfig
and returns it.- Parameters:
prototype
- theEurekaDiscoveryConfig
from which the implementation will be created; must not benull
- Returns:
- a new, non-
null
EurekaDiscovery
implementation - Throws:
NullPointerException
- ifprototype
isnull
- See Also:
-
create
A convenience method required by, and complying with the requirements of, the Helidon Builder API that, per contract, builds a newEurekaDiscovery
implementation and returns it.- Parameters:
consumer
- aConsumer
ofEurekaDiscoveryConfig.Builder
instances that typically mutates its suppliedEurekaDiscoveryConfig.Builder
; must not benull
- Returns:
- a new, non-
null
EurekaDiscovery
implementation as returned by theEurekaDiscoveryConfig.Builder.build()
method - Throws:
NullPointerException
- ifconsumer
isnull
- See Also:
-