Klasse CommandRateLimiter

java.lang.Object
de.delinkedde.areashopreborn.command.CommandRateLimiter

public final class CommandRateLimiter extends Object
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

    Konstruktoren
    Konstruktor
    Beschreibung
    CommandRateLimiter(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 Typ
    Methode
    Beschreibung
    boolean
    tryAcquire(String senderKey)
    Attempts to consume one command permit for a stable sender key.

    Von Klasse geerbte Methoden java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Konstruktordetails

    • CommandRateLimiter

      public CommandRateLimiter(double permitsPerSecond, int burst)
      Creates a rate limiter using monotonic system time.
      Parameter:
      permitsPerSecond - sustained accepted commands per sender and second
      burst - 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 second
      burst - maximum immediately available commands per sender
      maximumTrackedSenders - maximum simultaneous idle/non-idle buckets
  • Methodendetails

    • tryAcquire

      public boolean tryAcquire(String senderKey)
      Attempts to consume one command permit for a stable sender key.
      Parameter:
      senderKey - UUID or other stable sender identifier
      Gibt zurück:
      true when the command may proceed