MCPcopy Index your code
hub / github.com/InfinitiBit/graphbit / record_failure

Method record_failure

python/src/llm/client.rs:118–150  ·  view source on GitHub ↗
(&self)

Source from the content-addressed store, hash-verified

116 }
117
118 async fn record_failure(&self) {
119 if !self.config.circuit_breaker_enabled {
120 return;
121 }
122
123 let mut state = self.state.write().await;
124 match *state {
125 CircuitBreakerState::Closed { failure_count } => {
126 let new_count = failure_count + 1;
127 if new_count >= self.config.circuit_breaker_threshold {
128 *state = CircuitBreakerState::Open {
129 opened_at: Instant::now(),
130 };
131 if self.config.debug {
132 warn!("Circuit breaker opened due to {} failures", new_count);
133 }
134 } else {
135 *state = CircuitBreakerState::Closed {
136 failure_count: new_count,
137 };
138 }
139 }
140 CircuitBreakerState::HalfOpen => {
141 *state = CircuitBreakerState::Open {
142 opened_at: Instant::now(),
143 };
144 if self.config.debug {
145 warn!("Circuit breaker reopened after failed recovery attempt");
146 }
147 }
148 _ => {}
149 }
150 }
151}
152
153/// Client statistics for monitoring

Callers 1

Calls

no outgoing calls

Tested by

no test coverage detected