TsgcWSCircuitBreaker › Methods › IsMessageAllowed
Server-side gatekeeper that returns False when the ServerKey circuit is Open and rejects the message.
function IsMessageAllowed(const aIP: string; const aMessage: string = ''): Boolean;
| Name | Type | Description |
|---|---|---|
aIP | const string | Peer IP address of the sender. Accepted for logging and future per-IP metrics. |
aMessage | const string | Optional message payload or identifier — accepted so future releases can apply content-based classification; ignored by the current evaluation. |
True when the ServerKey circuit is Closed or HalfOpen with a remaining trial, False when Open. Returns True unconditionally while Enabled is False. (Boolean)
Server-side self-protection helper: delegates to IsCallAllowed(ServerKey). Call it from the server's OnMessage / BeforeMessage handlers and drop the message when it returns False so incoming traffic is shed while the server circuit is Open. Combine with RecordMessageSuccess / RecordMessageError so message-processing outcomes feed back into the breaker. This is a secondary server-integration hook — the primary use of the component is client-side protection of outbound HTTP API calls.
procedure TForm1.WSServerMessage(Connection: TsgcWSConnection;
const Text: string);
begin
if not sgcWSCircuitBreaker1.IsMessageAllowed(Connection.PeerIP, Text) then
Exit; // shed load while the server circuit is Open
try
HandleMessage(Text);
sgcWSCircuitBreaker1.RecordMessageSuccess(Connection.PeerIP);
except
on E: Exception do
sgcWSCircuitBreaker1.RecordMessageError(Connection.PeerIP, E.Message);
end;
end;