TsgcWSCircuitBreakerProperties › PerEndpoint

PerEndpoint Property

Collection of pattern-based overrides that apply different Thresholds/Recovery per host.

Syntax

property PerEndpoint: TsgcCircuitBreakerEndpointList read FPerEndpoint
      write SetPerEndpoint;

Default Value

Remarks

Each TsgcCircuitBreakerEndpointItem carries its own Pattern (wildcards * and ? supported), OverrideThresholds block and OverrideRecovery block. When the active key (usually the hostname derived from the outgoing URL) matches an enabled item, that item's settings replace the top-level Thresholds / Recovery for the duration of the call — the first enabled pattern match wins. Sub-properties: Enabled (False by default — when False no items are evaluated and only the top-level settings apply) and Items (a TCollection of endpoint overrides). Typical use: give api.openai.com lenient thresholds because it slows under load, while api.stripe.com opens fast because payment failures are critical.

Example

sgcWSCircuitBreaker1.PerEndpoint.Enabled := True;

// OpenAI - lenient: 10 failures, 60s cooldown
with sgcWSCircuitBreaker1.PerEndpoint.Items.Add as TsgcCircuitBreakerEndpointItem do
begin
  Pattern := 'api.openai.com';
  OverrideThresholds.Enabled := True;
  OverrideThresholds.FailureCount := 10;
  OverrideRecovery.CooldownSec := 60;
end;

// Stripe - payment critical: open fast, recover slow
with sgcWSCircuitBreaker1.PerEndpoint.Items.Add as TsgcCircuitBreakerEndpointItem do
begin
  Pattern := 'api.stripe.com';
  OverrideThresholds.Enabled := True;
  OverrideThresholds.FailureCount := 3;
  OverrideRecovery.CooldownSec := 120;
end;

Back to Properties