Skip to content

Commit 2686227

Browse files
committed
chore: simplified circuit breaker link
1 parent 08c0808 commit 2686227

File tree

1 file changed

+12
-7
lines changed

1 file changed

+12
-7
lines changed

src/handlers/handlerUtils.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -598,6 +598,7 @@ export async function tryTargetsRecursively(
598598

599599
// start: merge inherited config with current target config (preference given to current)
600600
const currentInheritedConfig: Record<string, any> = {
601+
id: inheritedConfig.id || currentTarget.id,
601602
overrideParams: {
602603
...inheritedConfig.overrideParams,
603604
...currentTarget.overrideParams,
@@ -751,8 +752,8 @@ export async function tryTargetsRecursively(
751752
];
752753
// end: merge inherited config with current target config (preference given to current)
753754

754-
const circuitBreakerConfigId = c.get('circuitBreakerConfigId');
755-
if (circuitBreakerConfigId) {
755+
const isHandlingCircuitBreaker = currentInheritedConfig.id;
756+
if (isHandlingCircuitBreaker) {
756757
const healthyTargets = (currentTarget.targets || [])
757758
.map((t: any, index: number) => ({
758759
...t,
@@ -891,10 +892,11 @@ export async function tryTargetsRecursively(
891892
currentJsonPath,
892893
method
893894
);
894-
if (circuitBreakerConfigId) {
895+
if (isHandlingCircuitBreaker) {
895896
await c.get('handleCircuitBreakerResponse')(
896897
response,
897-
circuitBreakerConfigId,
898+
currentInheritedConfig.id,
899+
currentTarget.cbConfig,
898900
currentJsonPath,
899901
c
900902
);
@@ -924,11 +926,13 @@ export async function tryTargetsRecursively(
924926
);
925927
} else {
926928
response = error.response;
927-
if (circuitBreakerConfigId) {
929+
if (isHandlingCircuitBreaker) {
928930
await c.get('recordCircuitBreakerFailure')(
929931
env(c),
930-
circuitBreakerConfigId,
931-
currentJsonPath
932+
currentInheritedConfig.id,
933+
currentTarget.cbConfig,
934+
currentJsonPath,
935+
response.status
932936
);
933937
}
934938
}
@@ -1240,6 +1244,7 @@ export function constructConfigFromRequestHeaders(
12401244
'output_guardrails',
12411245
'default_input_guardrails',
12421246
'default_output_guardrails',
1247+
'cb_config',
12431248
]) as any;
12441249
}
12451250

0 commit comments

Comments
 (0)