Skip to content

Commit

Permalink
feat(CircuitBreaker): independent DCR switch
Browse files Browse the repository at this point in the history
We want to be able to turn off the circuit
breaker for DCR independently of CAPI
  • Loading branch information
mxdvl committed May 14, 2024
1 parent 1fdcc37 commit 1df8dd0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
10 changes: 10 additions & 0 deletions common/app/conf/switches/PerformanceSwitches.scala
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,16 @@ trait PerformanceSwitches {
exposeClientSide = false,
)

val CircuitBreakerDcrSwitch = Switch(
SwitchGroup.Performance,
"circuit-breaker-dcr",
"If this switch is switched on then the DCR API circuit breaker will be operational",
owners = Seq(Owner.withEmail("[email protected]")),
safeState = Off,
sellByDate = never,
exposeClientSide = false,
)

val AutoRefreshSwitch = Switch(
SwitchGroup.Performance,
"auto-refresh",
Expand Down
4 changes: 2 additions & 2 deletions common/app/renderers/DotcomRenderingService.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import com.gu.contentapi.client.model.v1.{Block, Blocks, Content}
import common.{DCRMetrics, GuLogging}
import concurrent.CircuitBreakerRegistry
import conf.Configuration
import conf.switches.Switches.CircuitBreakerSwitch
import conf.switches.Switches.CircuitBreakerDcrSwitch
import crosswords.CrosswordPageWithContent
import http.{HttpPreconnections, ResultWithPreconnectPreload}
import model.Cached.{RevalidatableResult, WithoutRevalidationResult}
Expand Down Expand Up @@ -133,7 +133,7 @@ class DotcomRenderingService extends GuLogging with ResultWithPreconnectPreload
}
}

if (CircuitBreakerSwitch.isSwitchedOn) {
if (CircuitBreakerDcrSwitch.isSwitchedOn) {
circuitBreaker.withCircuitBreaker(postWithoutHandler(ws, payload, endpoint, timeout)).map(handler)
} else {
postWithoutHandler(ws, payload, endpoint, timeout).map(handler)
Expand Down

0 comments on commit 1df8dd0

Please sign in to comment.