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
The point of CachingServiceInstanceListSupplier is caching.
yes, but you can't cache infinite stream, you need to stop at some time. Flux is potentially infinite, so if you want to cache signals this way you need to get first List<ServiceInstance> in cache.
@OlgaMaciaszek what is wrong in making HealthCheckServiceInstanceListSupplier a bean?
And what about HealthCheckServiceInstanceListSupplier#destroy? if it is not a bean it should also be called manually
Activity
OlgaMaciaszek commentedon May 21, 2020
CC @robotmrv
robotmrv commentedon May 21, 2020
@OlgaMaciaszek
Hi, the reason of hanging is
CachingServiceInstanceListSupplierit tries to cache infiniteFluxfromHealthCheckServiceInstanceListSupplierand collect it toMono<List<Signal<List<ServiceInstance>>>>seehttps://github.com/spring-cloud/spring-cloud-commons/blob/master/spring-cloud-loadbalancer/src/main/java/org/springframework/cloud/loadbalancer/core/CachingServiceInstanceListSupplier.java#L71
I think it is redundant as
HealthCheckServiceInstanceListSuppliercaches latest resultspencergibb commentedon May 21, 2020
The point of
CachingServiceInstanceListSupplieris caching.robotmrv commentedon May 21, 2020
to be more correct, Flux is collected into List in https://github.com/reactor/reactor-addons/blob/master/reactor-extra/src/main/java/reactor/cache/CacheFlux.java#L103
one more thing
There is no call of
HealthCheckServiceInstanceListSupplier#afterPropertiesSetinhttps://github.com/OlgaMaciaszek/spring-cloud-example/blob/fixed-config/microservice-b/src/main/java/com/example/microserviceb/MicroserviceBApplication.java#L47
which will allow caching on
HealthCheckServiceInstanceListSuppliersideyes, but you can't cache infinite stream, you need to stop at some time.
Fluxis potentially infinite, so if you want to cache signals this way you need to get firstList<ServiceInstance>in cache.robotmrv commentedon May 21, 2020
Btw,
Fluxinfinity was discussed here. I understood that contract ofServiceInstanceListSupplierallows infinite streamsspencergibb commentedon May 21, 2020
ok, so what is cached may need to be adjusted.
OlgaMaciaszek commentedon May 21, 2020
Yes, we would not usually expect the users to manually call
afterPropertiesSet- I would move that back to constructor.OlgaMaciaszek commentedon May 21, 2020
Makes sense. Will probably need to adjust the
CachingServiceInstanceListSupplier.robotmrv commentedon May 21, 2020
@OlgaMaciaszek what is wrong in making
HealthCheckServiceInstanceListSuppliera bean?And what about
HealthCheckServiceInstanceListSupplier#destroy? if it is not a bean it should also be called manuallyOlgaMaciaszek commentedon May 21, 2020
That's a good point. We allow for tweaking the configs by creating hierarchies of delegates and we even have an easy way for users to do it via builders: see https://github.com/spring-cloud/spring-cloud-commons/blob/master/spring-cloud-loadbalancer/src/main/java/org/springframework/cloud/loadbalancer/core/ServiceInstanceListSuppliers.java, so we do not assume all delegates need to be beans, but as per @spencergibb suggestion, will change
DelegatingServiceInstanceListSupplier(which will be the type of the highest level ServiceInstanceListSupplier that will always be a bean) to implementDisposableBeanand if delegate is instance, calldispose(). Will move the code fromafterPropertiesSet()to method called in constructor.Fix execution thread for blocking and adjusts timing
merge from spring cloud commons master. (#1)