TsgcWSCircuitBreakerEvents › OnCallRejected

OnCallRejected Event

Fired when the breaker refuses a call because the circuit is Open or the HalfOpen trial budget is exhausted.

Syntax

property OnCallRejected: TsgcCircuitBreakerOnCallRejected;
// TsgcCircuitBreakerOnCallRejected = procedure(Sender: TObject; const aKey, aReason: string) of object

Default Value

Remarks

Fires every time IsCallAllowed, Execute, ExecuteWithResult, IsConnectionAllowed or IsMessageAllowed returns False. The aKey parameter identifies the circuit (usually a hostname or ServerKey), and aReason is a short human-readable string such as 'Circuit Open' or 'HalfOpen trial budget exhausted'. Metrics.TotalRejected is incremented before the event fires. Use this event to log rejected traffic, to emit a metric for alerting, or to update a visible degraded-mode indicator in the UI. Runs synchronously on the thread that made the call — keep the handler fast.

Example

procedure TForm1.CircuitCallRejected(Sender: TObject;
  const aKey, aReason: string);
begin
  Log(Format('Rejected call for %s (%s)', [aKey, aReason]));
  IncMetric('circuit.rejected.' + aKey);
end;

Back to Events