Record Class RateLimitKey

java.lang.Object
java.lang.Record
com.svenruppert.jsentinel.ratelimiting.RateLimitKey
Record Components:
tenant - tenant scope; null becomes TenantId.DEFAULT
scope - non-blank dimension string

@ExperimentalJSentinelApi public record RateLimitKey(TenantId tenant, String scope) extends Record
Composite key under which RateLimitStore tracks event timestamps for sliding-window rate-limiting.

The scope component is a free-form string that the policy layer (planned for V00.70 Phase 7c) composes from whatever dimensions the application wants to limit on — typical examples:

  • "ip:1.2.3.4" — per source IP.
  • "subject:alice" — per authenticated user.
  • "endpoint:POST /api/login" — per HTTP endpoint.
  • "ip:1.2.3.4|endpoint:POST /api/login" — combined.

Keeping the scope as an opaque string keeps the store itself dimension-agnostic; the policy decides naming conventions and is free to evolve them without changing the store contract.

  • Constructor Details

    • RateLimitKey

      public RateLimitKey(TenantId tenant, String scope)
      Validates the record components and normalises a null tenant to TenantId.DEFAULT.
      Parameters:
      tenant - tenant scope; null becomes DEFAULT
      scope - non-blank scope
  • Method Details

    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared with Objects::equals(Object,Object).
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • tenant

      public TenantId tenant()
      Returns the value of the tenant record component.
      Returns:
      the value of the tenant record component
    • scope

      public String scope()
      Returns the value of the scope record component.
      Returns:
      the value of the scope record component