TsgcWSCircuitBreaker › Methods › IsConnectionAllowed
Server-side gatekeeper that returns False while the ServerKey circuit is Open.
function IsConnectionAllowed(const aIP: string): Boolean;
| Name | Type | Description |
|---|---|---|
aIP | const string | Peer IP address of the inbound connection. Accepted for logging and future per-IP metrics; the actual decision is taken against ServerKey. |
True when the ServerKey circuit is Closed or HalfOpen, False when it is Open. Returns True unconditionally while Enabled is False. (Boolean)
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.
procedure TForm1.WSServerConnect(Connection: TsgcWSConnection);
begin
if not sgcWSCircuitBreaker1.IsConnectionAllowed(Connection.PeerIP) then
begin
Connection.Disconnect;
Exit;
end;
sgcWSCircuitBreaker1.RegisterConnection(Connection.PeerIP);
end;