Klasse CommandRateLimiter
java.lang.Object
de.delinkedde.areashopreborn.command.CommandRateLimiter
Provides an in-memory token bucket per command sender without database or scheduler work.
Idle buckets are removed opportunistically, so historical senders do not accumulate for the lifetime of the server. A burst permits normal multi-command workflows while sustained macro traffic is rejected before it reaches SQLite or platform integrations.
-
Konstruktorübersicht
KonstruktorenKonstruktorBeschreibungCommandRateLimiter(double permitsPerSecond, int burst) Creates a rate limiter using monotonic system time.CommandRateLimiter(double permitsPerSecond, int burst, int maximumTrackedSenders) Creates a rate limiter with a hard retained-sender ceiling. -
Methodenübersicht
Modifizierer und TypMethodeBeschreibungbooleantryAcquire(String senderKey) Attempts to consume one command permit for a stable sender key.
-
Konstruktordetails
-
CommandRateLimiter
public CommandRateLimiter(double permitsPerSecond, int burst) Creates a rate limiter using monotonic system time.- Parameter:
permitsPerSecond- sustained accepted commands per sender and secondburst- maximum immediately available commands per sender
-
CommandRateLimiter
public CommandRateLimiter(double permitsPerSecond, int burst, int maximumTrackedSenders) Creates a rate limiter with a hard retained-sender ceiling.- Parameter:
permitsPerSecond- sustained accepted commands per sender and secondburst- maximum immediately available commands per sendermaximumTrackedSenders- maximum simultaneous idle/non-idle buckets
-
-
Methodendetails
-
tryAcquire
Attempts to consume one command permit for a stable sender key.- Parameter:
senderKey- UUID or other stable sender identifier- Gibt zurück:
truewhen the command may proceed
-