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

  1. 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.
  2. Each event represents the current state of the ServiceDiscovererEvent overriding any previously known ServiceDiscovererEvent.Status and any associated meta-data.
Item 1 is required to satisfy Reactive Streams Rule 1.10, which requires every subscribe to happen with a new 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.