solution: config option to disable an upstream

This commit is contained in:
Igor Artamonov
2021-12-26 15:32:18 -05:00
parent b397a907b1
commit 45237592a3
3 changed files with 12 additions and 0 deletions

View File

@@ -616,6 +616,11 @@ Fallback role mean that the upstream is used only after other upstreams failed o
Cluster may have multiple upstreams for a single blockchain.
Accepted types: `bitcoin`, `bitcoin-testnet`, `ethereum`, `ethereum-classic`, `kovan-testnet`, `rinkeby-testnet`, `ropsten-testnet`, or `goerli-testnet`
| `enabled`
| no
| `true` (default) or `false`.
Enable/disable the upstream.
| `labels`
| no
| Key-Value pairs that are assigned to the upstream.

View File

@@ -194,6 +194,9 @@ class UpstreamsConfigReader(
upstream.id = getValueAsString(upNode, "id")
upstream.options = tryReadOptions(upNode)
upstream.methods = tryReadMethods(upNode)
getValueAsBool(upNode, "enabled")?.let {
upstream.isEnabled = it
}
}
internal fun readUpstreamGrpc(

View File

@@ -63,6 +63,10 @@ open class ConfiguredUpstreams(
log.debug("Starting upstreams")
val defaultOptions = buildDefaultOptions(config)
config.upstreams.forEach { up ->
if (!up.isEnabled) {
log.debug("Upstream ${up.id} is disabled")
return@forEach
}
log.debug("Start upstream ${up.id}")
if (up.connection is UpstreamsConfig.GrpcConnection) {
val options = up.options ?: UpstreamsConfig.Options()