From 168d2c3268f170ad93d227945a4abdb31e238c4b Mon Sep 17 00:00:00 2001 From: Thushani Jayasekera Date: Thu, 12 Dec 2024 00:18:36 +0530 Subject: [PATCH] Adding circuit breaking configs if org is paid --- .../internal/oasparser/model/mgw_swagger.go | 29 +++++++------------ 1 file changed, 11 insertions(+), 18 deletions(-) diff --git a/adapter/internal/oasparser/model/mgw_swagger.go b/adapter/internal/oasparser/model/mgw_swagger.go index a7bccc425c..164fcc4714 100644 --- a/adapter/internal/oasparser/model/mgw_swagger.go +++ b/adapter/internal/oasparser/model/mgw_swagger.go @@ -181,6 +181,7 @@ const prototypedAPI = "prototyped" // BasicCircuitBreaker is the name for free tier cluster level circuit breaker const BasicCircuitBreaker = "BasicCircuitBreaker" +const EnhancedCircuitBreaker = "EnhancedCircuitBreaker" // GetCorsConfig returns the CorsConfiguration Object. func (swagger *MgwSwagger) GetCorsConfig() *CorsConfig { @@ -686,8 +687,16 @@ func (endpointCluster *EndpointCluster) SetEndpointsConfig(endpointInfos []Endpo var selectedCircuitBreaker *CircuitBreakers for _, circuitBreaker := range conf.Envoy.Upstream.CircuitBreakers { - // check ispaidorg from here - if utills.GetIsOrganizationInList(orgID, circuitBreaker.Organizations) { + if isChoreoOrgPaid && circuitBreaker.CircuitBreakerName == EnhancedCircuitBreaker { + selectedCircuitBreaker = createCircuitBreaker( + circuitBreaker.MaxConnections, + circuitBreaker.MaxPendingRequests, + circuitBreaker.MaxRequests, + circuitBreaker.MaxRetries, + circuitBreaker.MaxConnectionPools, + ) + break + } else if !isChoreoOrgPaid && circuitBreaker.CircuitBreakerName == BasicCircuitBreaker { selectedCircuitBreaker = createCircuitBreaker( circuitBreaker.MaxConnections, circuitBreaker.MaxPendingRequests, @@ -696,22 +705,6 @@ func (endpointCluster *EndpointCluster) SetEndpointsConfig(endpointInfos []Endpo circuitBreaker.MaxConnectionPools, ) break - } - } - if selectedCircuitBreaker == nil { - for _, circuitBreaker := range conf.Envoy.Upstream.CircuitBreakers { - // breaks from the first iteration - if circuitBreaker.CircuitBreakerName == BasicCircuitBreaker { - selectedCircuitBreaker = createCircuitBreaker( - circuitBreaker.MaxConnections, - circuitBreaker.MaxPendingRequests, - circuitBreaker.MaxRequests, - circuitBreaker.MaxRetries, - circuitBreaker.MaxConnectionPools, - ) - break - } - } } endpointCluster.Config.CircuitBreakers = selectedCircuitBreaker