Interface ServiceDiscoverer<UnresolvedAddress,ResolvedAddress,E extends ServiceDiscovererEvent<ResolvedAddress>>
- Type Parameters:
UnresolvedAddress
- The type of address before resolution.ResolvedAddress
- The type of address after resolution.E
- Type ofServiceDiscovererEvent
s published fromdiscover(Object)
.
- All Superinterfaces:
AsyncCloseable
,ListenableAsyncCloseable
- All Known Implementing Classes:
DelegatingServiceDiscoverer
discover(Object)
is called that the service discovery system will push data updates or implementations of this interface will poll for
data updates. Changes in the available addresses will be communicated via the resulting Publisher
.
Because typically a ServiceDiscoverer
implementation runs in the background and doesn't require many compute
resources, it's recommended (but not required) to run it and deliver updates on a single thread either for all
discoveries or at least for all Subscribers
to the same Publisher
. One possible advantage
of a single-threaded model is that it will make debugging easier as discovery events and the logs they generate will
be less susceptible to reordering.
See ServiceDiscovererEvent
for documentation regarding the interpretation of events.
-
Method Summary
Modifier and TypeMethodDescriptiondiscover
(UnresolvedAddress address) Subscribe to the service discovery system for changes in the availableServiceDiscoverer
associated withaddress
.Methods inherited from interface io.servicetalk.concurrent.api.AsyncCloseable
closeAsync, closeAsyncGracefully
Methods inherited from interface io.servicetalk.concurrent.api.ListenableAsyncCloseable
onClose, onClosing
-
Method Details
-
discover
Subscribe to the service discovery system for changes in the availableServiceDiscoverer
associated withaddress
.In general a call to this method will continue to discover changes related to
address
until theSubscription
corresponding to the return value iscancelled
orPublisher
fails with an error. The returnedPublisher
should nevercomplete
because underlying system may run for a long period of time and updates may be required at any time in the future. The returnedPublisher
MUST support re-subscribes to allow underlying systems retry failures or re-subscribe aftercancellation
.- Parameters:
address
- the service address to discover. Examples of what this address maybe are:- hostname/port (e.g. InetAddress)
- service name
- it may be a list of attributes which describe the service attributes to resolve
- something else
- Returns:
- a
Publisher
that represents a stream of events from the service discovery system.
-