Adjustments in availability determination:

- now isAvailable return true in case upstreams are OK or LAGGING
- All upstreams in Filtered API now sorted by status
This commit is contained in:
a10zn8
2023-02-13 18:48:01 +04:00
parent 1b83e99cff
commit 6d78b4927d
3 changed files with 38 additions and 4 deletions

View File

@@ -65,7 +65,7 @@ abstract class DefaultUpstream(
}
override fun isAvailable(): Boolean {
return getStatus() == UpstreamAvailability.OK
return getStatus() == UpstreamAvailability.OK || getStatus() == UpstreamAvailability.LAGGING
}
fun onStatus(value: BlockchainOuterClass.ChainStatus) {

View File

@@ -160,11 +160,11 @@ class FilteredApis(
override fun subscribe(subscriber: Subscriber<in Upstream>) {
// initially try only standard upstreams
val first = Flux.fromIterable(primaryUpstreams)
val second = Flux.fromIterable(secondaryUpstreams)
val first = Flux.fromIterable(primaryUpstreams.sortedBy { it.getStatus().grpcId })
val second = Flux.fromIterable(secondaryUpstreams.sortedBy { it.getStatus().grpcId })
// if all failed, try both standard and fallback upstreams, repeating in cycle
val retries = (0 until (retryLimit - 1)).map { r ->
Flux.fromIterable(standardWithFallback)
Flux.fromIterable(standardWithFallback.sortedBy { it.getStatus().grpcId })
// add a delay to let upstream to restore if it's a temp failure
// but delay only start of the check, not between upstreams
// i.e. if all upstreams failed -> wait -> check all without waiting in between