TsgcWSRateLimiterEvents › OnQuotaExceeded

OnQuotaExceeded Event

Fired when a long-term quota is reached for a key.

Syntax

property OnQuotaExceeded: TsgcRateLimitOnQuotaExceeded;
// TsgcRateLimitOnQuotaExceeded = procedure(Sender: TObject; const aKey, aQuotaName: string) of object

Default Value

Remarks

Fired from inside Consume when a TsgcRateLimitQuotaItem reaches its configured Limit for the current period (hour / day / month). The aKey parameter is the rate-limit key that exhausted the quota and aQuotaName is the Name of the quota item, matching the Result.Reason ("quota:Name"). Use this event to notify operations (send an email to the customer, post to a Slack / Teams channel, write an audit log entry, push a banner to the UI) — the request is still rejected regardless of what the handler does, so use OnThrottled if you want to overturn the decision.

Example

procedure TForm1.RateLimiterQuotaExceeded(Sender: TObject;
  const aKey, aQuotaName: string);
begin
  Log('Quota ' + aQuotaName + ' exceeded for ' + aKey);
  NotifyOperations(aKey, aQuotaName);
end;

Back to Events