Class ServiceDiscovererUtils
java.lang.Object
io.servicetalk.dns.discovery.netty.ServiceDiscovererUtils
A set of utility functions for
ServiceDiscoverer.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceRepresents an operation that accepts twoint-valued arguments and returns no result. -
Method Summary
Modifier and TypeMethodDescriptionstatic <T> List<ServiceDiscovererEvent<T>>calculateDifference(List<? extends T> currentActiveAddresses, List<? extends T> newActiveAddresses, Comparator<T> comparator, ServiceDiscovererUtils.TwoIntsConsumer reporter, ServiceDiscovererEvent.Status missingRecordStatus) Given a sorted list of currently active addresses, and a new set of unsorted active address calculate theServiceDiscovererEvents.
-
Method Details
-
calculateDifference
@Nullable public static <T> List<ServiceDiscovererEvent<T>> calculateDifference(List<? extends T> currentActiveAddresses, List<? extends T> newActiveAddresses, Comparator<T> comparator, @Nullable ServiceDiscovererUtils.TwoIntsConsumer reporter, ServiceDiscovererEvent.Status missingRecordStatus) Given a sorted list of currently active addresses, and a new set of unsorted active address calculate theServiceDiscovererEvents.newActiveAddresseswill be sorted in this method.- Type Parameters:
T- The type of address.- Parameters:
currentActiveAddresses- The currently active addresses.newActiveAddresses- The new list of active addresses.This list must be modifiable as it will be sorted withList.sort(Comparator).comparator- A comparator for the addresses and to use for binary searches.reporter- A reporter for the numbers of available and missing events.missingRecordStatus-ServiceDiscovererEvent.Statusto use for createdServiceDiscovererEventwhen address present in current list but not in the new one.- Returns:
- A list of
ServiceDiscovererEvents which represents the changes betweencurrentActiveAddressesandnewActiveAddresses, ornullif there are no changes.
-