TsgcWSCircuitBreakerMethods › IsConnectionAllowed

IsConnectionAllowed Method

Server-side gatekeeper that returns False while the ServerKey circuit is Open.

Syntax

function IsConnectionAllowed(const aIP: string): Boolean;

Parameters

NameTypeDescription
aIPconst stringPeer IP address of the inbound connection. Accepted for logging and future per-IP metrics; the actual decision is taken against ServerKey.

Return Value

True when the ServerKey circuit is Closed or HalfOpen, False when it is Open. Returns True unconditionally while Enabled is False. (Boolean)

Remarks

Server-side self-protection helper: delegates to IsCallAllowed(ServerKey). Call it from the server's OnConnect / BeforeAccept handlers and disconnect the peer when it returns False so new clients are turned away while the server is in the Open state (for example while a critical downstream is down). The method only returns True / False — it does not log or disconnect by itself. The primary use of this component is client-side protection of outbound HTTP API calls; connection-allowance is a secondary server-integration hook.

Example

procedure TForm1.WSServerConnect(Connection: TsgcWSConnection);
begin
  if not sgcWSCircuitBreaker1.IsConnectionAllowed(Connection.PeerIP) then
  begin
    Connection.Disconnect;
    Exit;
  end;
  sgcWSCircuitBreaker1.RegisterConnection(Connection.PeerIP);
end;

Back to Methods