problem: chain backed by single grpc upstream is unavailable

This commit is contained in:
Igor Artamonov
2019-10-16 00:03:24 -04:00
parent 77685c314a
commit cdb631dbf8
2 changed files with 28 additions and 6 deletions

View File

@@ -58,6 +58,9 @@ class CurrentUpstreams(
} else {
current.addUpstream(up)
}
if (!callTargets.containsKey(chain)) {
setupDefaultMethods(chain)
}
log.info("Upstream ${change.upstream.getId()} with chain $chain has been added")
}
}
@@ -84,12 +87,13 @@ class CurrentUpstreams(
}
override fun getDefaultMethods(chain: Chain): CallMethods {
var current = callTargets[chain]
if (current == null) {
current = QuorumBasedMethods(objectMapper, chain)
callTargets[chain] = current
}
return current
return callTargets[chain] ?: return setupDefaultMethods(chain)
}
fun setupDefaultMethods(chain: Chain): QuorumBasedMethods {
val created = QuorumBasedMethods(objectMapper, chain)
callTargets[chain] = created
return created
}
override fun isAvailable(chain: Chain): Boolean {