TsgcWSCircuitBreakerProperties › DefaultKey

DefaultKey Property

Key used by the parameterless overloads of Execute, RecordSuccess and RecordFailure.

Syntax

property DefaultKey: string read FDefaultKey write FDefaultKey;

Default Value

Remarks

Every circuit is tracked by a string key — the client-side integration derives the key from the target hostname automatically, but when you drive the breaker manually through Execute / RecordSuccess / RecordFailure the parameterless overloads fall back to this value. Set DefaultKey to a meaningful name (for example 'openai-api', 'payment-gateway' or 'primary-db') so counters, Metrics and OnStateChange events are grouped under a human-readable label. The default is 'default'. DefaultKey only affects calls made without an explicit key; the server-side helpers use ServerKey and the HTTP API client integration uses the actual hostname instead.

Example

// Use a meaningful key so Metrics and events report a readable label
sgcWSCircuitBreaker1.DefaultKey := 'openai-api';

// Now the parameterless overloads target the 'openai-api' circuit
sgcWSCircuitBreaker1.Execute(
  procedure
  begin
    CallOpenAI;
  end);

Back to Properties