Package io.servicetalk.client.api
Interface ServiceDiscovererEvent<ResolvedAddress>
- Type Parameters:
ResolvedAddress
- the type of address after resolution.
- All Known Subinterfaces:
PartitionedServiceDiscovererEvent<ResolvedAddress>
- All Known Implementing Classes:
DefaultServiceDiscovererEvent
public interface ServiceDiscovererEvent<ResolvedAddress>
Notification from the Service Discovery system that availability for an address has changed.
Interpreting Events
- When subscribing (or re-subscribing to recover from failures) to an event stream the initial collection of events is considered to be the current state of the world.
- Each event represents the current state of the
ServiceDiscovererEvent
overriding any previously knownServiceDiscovererEvent.Status
and any associated meta-data.
Subscriber
.
As a result, Subscriber
needs to know the initial state to start from.
Item 2 can be clarified by the following example: we can represent a ServiceDiscovererEvent
as map entries of
the form (ServiceDiscovererEvent
, (ServiceDiscovererEvent.Status
, meta-data)) where the ServiceDiscovererEvent
is the map key.
Starting with the initial state of {addr1, (AVAILABLE, meta-1)}. Upon subscribing to the event stream the initial state is populated via the event (addr1, (AVAILABLE, meta-1)). Say the meta-data for address changes resulting in a system state {addr1, (AVAILABLE, meta-2)}. The state change is be represented by the event (addr1, (AVAILABLE, meta-2)). Next the address is removed from the system resulting in an empty state {}. It is up to theSeeServiceDiscoverer
whether this will be represented by theServiceDiscovererEvent.Status.UNAVAILABLE
orServiceDiscovererEvent.Status.EXPIRED
but both are logically equivalent to removal, only with different meanings for how resources already acquired to the address should be used. Picking UNAVAILABLE, the transition back to the empty state would be represented by the event (addr1, (UNAVAILABLE, meta-2)).
ServiceDiscoverer
for the interface that defines the source of event streams.-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final class
Status provided by theServiceDiscoverer
system that guides the actions ofLoadBalancer
upon the boundaddress()
(viaServiceDiscovererEvent
). -
Method Summary
Modifier and TypeMethodDescriptionaddress()
Get the resolved address which is the subject of this event.status()
Status
of the event instructing theServiceDiscoverer
what actions to take upon the associatedaddress
.
-
Method Details
-
address
ResolvedAddress address()Get the resolved address which is the subject of this event.- Returns:
- a resolved address that can be used for connecting.
-
status
ServiceDiscovererEvent.Status status()Status
of the event instructing theServiceDiscoverer
what actions to take upon the associatedaddress
.
-