Skip to content

Commit

Permalink
Adding circuit breaking configs if org is paid
Browse files Browse the repository at this point in the history
  • Loading branch information
Thushani-Jayasekera committed Dec 11, 2024
1 parent 071bf3c commit 168d2c3
Showing 1 changed file with 11 additions and 18 deletions.
29 changes: 11 additions & 18 deletions adapter/internal/oasparser/model/mgw_swagger.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -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,
Expand All @@ -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
Expand Down

0 comments on commit 168d2c3

Please sign in to comment.