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
ServiceDiscovererEventoverriding any previously knownServiceDiscovererEvent.Statusand 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 the
ServiceDiscoverer whether this will be represented by the ServiceDiscovererEvent.Status.UNAVAILABLE or
ServiceDiscovererEvent.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)).
See ServiceDiscoverer for the interface that defines the source of event streams.-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final classStatus provided by theServiceDiscoverersystem that guides the actions ofLoadBalancerupon the boundaddress()(viaServiceDiscovererEvent). -
Method Summary
Modifier and TypeMethodDescriptionaddress()Get the resolved address which is the subject of this event.status()Statusof the event instructing theServiceDiscovererwhat 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()Statusof the event instructing theServiceDiscovererwhat actions to take upon the associatedaddress.
-