TsgcWSCircuitBreakerMethods › RecordSuccess

RecordSuccess Method

Records a successful call; advances HalfOpen -> Closed when trial calls succeed.

Overloads

Overload 1

Syntax

procedure RecordSuccess(const aKey: string);

Parameters

NameTypeDescription
aKeyconst stringCircuit key the success belongs to — usually the hostname of the upstream service.

Remarks

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.

Example

// 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;

Overload 2

Syntax

procedure RecordSuccess;

Remarks

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.

Example

sgcWSCircuitBreaker1.DefaultKey := 'payment-gateway';
try
  ChargeCustomer;
  sgcWSCircuitBreaker1.RecordSuccess;
except
  on E: Exception do
    sgcWSCircuitBreaker1.RecordFailure(E.Message);
end;

Back to Methods