Disable liveness validation (#666)

* Disable liveness validation

* Update liveness validation to be configurable via options

* Refactor liveness subscription validation logic for improved readability
This commit is contained in:
Anton
2025-05-21 14:53:54 +03:00
committed by GitHub
parent 5d956d033d
commit 91749c0fa2
5 changed files with 28 additions and 19 deletions

View File

@@ -104,7 +104,7 @@ open class GenericUpstream(
private val lowerBlockDetectorSubscription = AtomicReference<Disposable?>()
private val settingsDetectorSubscription = AtomicReference<Disposable?>()
private val hasLiveSubscriptionHead: AtomicBoolean = AtomicBoolean(false)
private val hasLiveSubscriptionHead: AtomicBoolean = AtomicBoolean(getOptions().disableLivenessSubscriptionValidation)
protected val connector: GenericConnector = connectorFactory.create(this, chain)
private val livenessSubscription = AtomicReference<Disposable?>()
private val settingsDetector = upstreamSettingsDetectorBuilder(chain, this)
@@ -323,22 +323,24 @@ open class GenericUpstream(
?.subscribe(this::setStatus),
)
}
livenessSubscription.set(
connector.headLivenessEvents().subscribe(
{
val hasSub = it == HeadLivenessState.OK
hasLiveSubscriptionHead.set(hasSub)
if (it == HeadLivenessState.FATAL_ERROR) {
headLivenessState.emitNext(UPSTREAM_FATAL_SETTINGS_ERROR) { _, res -> res == Sinks.EmitResult.FAIL_NON_SERIALIZED }
} else {
sendUpstreamStateEvent(UPDATED)
}
},
{
log.debug("Error while checking live subscription for ${getId()}", it)
},
),
)
if (!getOptions().disableLivenessSubscriptionValidation) {
livenessSubscription.set(
connector.headLivenessEvents().subscribe(
{
val hasSub = it == HeadLivenessState.OK
hasLiveSubscriptionHead.set(hasSub)
if (it == HeadLivenessState.FATAL_ERROR) {
headLivenessState.emitNext(UPSTREAM_FATAL_SETTINGS_ERROR) { _, res -> res == Sinks.EmitResult.FAIL_NON_SERIALIZED }
} else {
sendUpstreamStateEvent(UPDATED)
}
},
{
log.debug("Error while checking live subscription for ${getId()}", it)
},
),
)
}
detectSettings()
detectLowerBlock()