From 1df8dd05a197e82aee579ce90b4b943dbd621a69 Mon Sep 17 00:00:00 2001 From: Max Duval Date: Tue, 14 May 2024 17:25:33 +0100 Subject: [PATCH] feat(CircuitBreaker): independent DCR switch We want to be able to turn off the circuit breaker for DCR independently of CAPI --- common/app/conf/switches/PerformanceSwitches.scala | 10 ++++++++++ common/app/renderers/DotcomRenderingService.scala | 4 ++-- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/common/app/conf/switches/PerformanceSwitches.scala b/common/app/conf/switches/PerformanceSwitches.scala index ac9c1379f4c7..644238c10a14 100644 --- a/common/app/conf/switches/PerformanceSwitches.scala +++ b/common/app/conf/switches/PerformanceSwitches.scala @@ -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("dotcom.platform@theguardian.com")), + safeState = Off, + sellByDate = never, + exposeClientSide = false, + ) + val AutoRefreshSwitch = Switch( SwitchGroup.Performance, "auto-refresh", diff --git a/common/app/renderers/DotcomRenderingService.scala b/common/app/renderers/DotcomRenderingService.scala index 18f7d2c3f990..f820ecdcbfdb 100644 --- a/common/app/renderers/DotcomRenderingService.scala +++ b/common/app/renderers/DotcomRenderingService.scala @@ -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} @@ -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)