Class ServiceDiscovererUtils
- java.lang.Object
-
- io.servicetalk.client.api.internal.ServiceDiscovererUtils
-
public final class ServiceDiscovererUtils extends java.lang.Object
A set of utility functions forServiceDiscoverer
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
ServiceDiscovererUtils.TwoIntsConsumer
Represents an operation that accepts twoint
-valued arguments and returns no result.
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> java.util.List<ServiceDiscovererEvent<T>>
calculateDifference(java.util.List<? extends T> currentActiveAddresses, java.util.List<? extends T> newActiveAddresses, java.util.Comparator<T> comparator, ServiceDiscovererUtils.TwoIntsConsumer reporter)
Given a sorted list of currently active addresses, and a new set of unsorted active address calculate theServiceDiscovererEvent
s.
-
-
-
Method Detail
-
calculateDifference
@Nullable public static <T> java.util.List<ServiceDiscovererEvent<T>> calculateDifference(java.util.List<? extends T> currentActiveAddresses, java.util.List<? extends T> newActiveAddresses, java.util.Comparator<T> comparator, @Nullable ServiceDiscovererUtils.TwoIntsConsumer reporter)
Given a sorted list of currently active addresses, and a new set of unsorted active address calculate theServiceDiscovererEvent
s.newActiveAddresses
will 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 unavailable events.- Returns:
- A list of
ServiceDiscovererEvent
s which represents the changes betweencurrentActiveAddresses
andnewActiveAddresses
, ornull
if there are no changes.
-
-