TsgcWSRateLimiterProperties › Stats

Stats Property

Read-only counters with live statistics about evaluated and throttled requests.

Syntax

property Stats: TsgcRateLimitStats read FStats;

Default Value

Remarks

Exposes TotalRequests, TotalThrottled, TotalQuotaExceeded, ActiveKeys and Uptime (seconds since the counters were last reset). All counters are updated atomically inside the component's internal critical section, so they can be polled safely from any thread. Typical use is a live dashboard in an admin UI: poll Stats from a TTimer and paint the values in labels, gauges or charts so operators can watch traffic pressure in real time. Counters are cleared by ResetAll.

Example

// Poll from a TTimer and update a dashboard
procedure TForm1.StatsTimer(Sender: TObject);
begin
  LabelRequests.Caption := Format('Requests: %d', [sgcWSRateLimiter1.Stats.TotalRequests]);
  LabelThrottled.Caption := Format('Throttled: %d', [sgcWSRateLimiter1.Stats.TotalThrottled]);
  LabelActiveKeys.Caption := Format('Active keys: %d', [sgcWSRateLimiter1.Stats.ActiveKeys]);
  LabelUptime.Caption := Format('Uptime: %d s', [sgcWSRateLimiter1.Stats.Uptime]);
end;

Back to Properties