You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
At the moment, the service discovery providers using the cache support (extending io.smallrye.stork.impl.CachingServiceDiscovery) are limited to a time-based cache. This issue is about allowing more advanced strategies such as background invalidation.
Design idea:
Add a method to CachingServiceDiscovery that allows customizing the "memorize" part of the pipeline:
// ...publicCachingServiceDiscovery(StringrefreshPeriod) {
try {
this.refreshPeriod = DurationUtils.parseDuration(refreshPeriod, REFRESH_PERIOD);
} catch (DateTimeParseExceptione) {
thrownewIllegalArgumentException(REFRESH_PERIOD + " for service discovery should be a number, got: " +
refreshPeriod,
e);
}
this.lastResults = Collections.emptyList();
uni<ServiceInstance> list = Uni.createFrom().deferred(() -> fetchNewServiceInstances(this.lastResults)
.invoke(l -> this.lastResults = l)
.onFailure().invoke(this::handleFetchError)
.onFailure().recoverWithItem(this.lastResults));
this.instances = cache(list);
}
// Overridable by the providerpublicUni<ServiceInstance> cache(Uni<ServiceInstance> uni) {
returnuni.memoize().atLeast(this.refreshPeriod);
}
To implement background invalidation, the provider would do something like:
(This is the first step of #299)
At the moment, the service discovery providers using the cache support (extending
io.smallrye.stork.impl.CachingServiceDiscovery
) are limited to a time-based cache. This issue is about allowing more advanced strategies such as background invalidation.Design idea:
Add a method to
CachingServiceDiscovery
that allows customizing the "memorize" part of the pipeline:To implement background invalidation, the provider would do something like:
The text was updated successfully, but these errors were encountered: