TsgcWSCircuitBreaker › Methods › RecordSuccess
Records a successful call; advances HalfOpen -> Closed when trial calls succeed.
procedure RecordSuccess(const aKey: string);
| Name | Type | Description |
|---|---|---|
aKey | const string | Circuit key the success belongs to — usually the hostname of the upstream service. |
Updates the rolling-window counters for the key, increments Metrics.TotalSuccesses and Metrics.TotalCalls, and evaluates the transition machine. In the HalfOpen state, every recorded success decrements the remaining trial budget; when it reaches zero the circuit transitions HalfOpen -> Closed and OnStateChange fires. Call RecordSuccess explicitly only when you manage the call yourself (not through Execute); the HTTP API client integration already records success on every 2xx response.
// Manual accounting after a custom REST call
try
vResponse := MyHTTPClient.Get(vURL);
sgcWSCircuitBreaker1.RecordSuccess(vHost);
except
on E: Exception do
sgcWSCircuitBreaker1.RecordFailure(vHost, E.Message);
end;
procedure RecordSuccess;
Shortcut that records a success against DefaultKey. Use when a single breaker protects exactly one logical dependency and passing the key on every call adds no value. Set DefaultKey to a meaningful label (for example 'payment-gateway') before calling so Metrics and OnStateChange are readable.
sgcWSCircuitBreaker1.DefaultKey := 'payment-gateway';
try
ChargeCustomer;
sgcWSCircuitBreaker1.RecordSuccess;
except
on E: Exception do
sgcWSCircuitBreaker1.RecordFailure(E.Message);
end;