TsgcWSCircuitBreakerProperties › ServerKey

ServerKey Property

Key used by the server-side integration hooks (IsConnectionAllowed, IsMessageAllowed, RecordMessageError, RecordMessageSuccess).

Syntax

property ServerKey: string read FServerKey write FServerKey;

Default Value

Remarks

When the circuit breaker is used to protect a WebSocket / HTTP server (self-protection mode) the server-side helpers — IsConnectionAllowed, IsMessageAllowed, RecordMessageError, RecordMessageSuccess, RegisterConnection, UnregisterConnection — all record activity against a single logical circuit identified by ServerKey. The default value is 'server'. Change it when multiple cooperating servers share one breaker instance and you want each to appear under its own label in Metrics and OnStateChange events. ServerKey is independent of DefaultKey: DefaultKey applies to manual Execute / RecordSuccess / RecordFailure calls and typically names an outbound dependency, whereas ServerKey names the server itself.

Example

// Label the self-protection circuit with a human-readable name
sgcWSCircuitBreaker1.ServerKey := 'ws-server:8443';

// Server-side handlers route through ServerKey automatically
if not sgcWSCircuitBreaker1.IsConnectionAllowed(Connection.PeerIP) then
  Connection.Disconnect;

Back to Properties