Record Class LimiterEvent

java.lang.Object
java.lang.Record
ai.redouble.nucleo.events.LimiterEvent
Record Components:
snapshot - the owning job's snapshot (nullable for transitions with no owning job)
timestamp - event creation time
limiterName - stable name of the account ("memory", "PubMed", "epo:search", etc.)
limiterCategory - "memory" | "token_bucket" | "elastic_window" | "semaphore"
capacity - configured capacity of the account (constant per instance, carried for self-describing events)
inUse - post-transition in-use count
waiters - post-transition count of jobs held on this account
type - transition type
waitNanos - wait duration (populated on GRANTED_FROM_HOLD and REJECTED-after-HELD; 0 otherwise)
rejectReason - free-form reason string (null unless type is REJECTED; conventional values: cancelled, shutdown, circuit_blocked, aborted)
statusIndicator - short tag describing an abnormal state ("blocked", "probing", "throttle:2.0x", "pace:1500ms"); null when the account is nominal
amount - units of capacity moved by this transition: tokens granted on GRANTED_*, requested on HELD/REJECTED, returned on RELEASED. For unit-permit accounts (semaphore, memory gate) this is 1 per permit. Consumers can sum amount for GRANTED_* events over a sliding window to compute true throughput, which inUse (a bucket-fill snapshot) does not represent.
All Implemented Interfaces:
OperationalEvent, JobEvent

public record LimiterEvent(JobSnapshot snapshot, Instant timestamp, String limiterName, String limiterCategory, long capacity, long inUse, int waiters, LimiterEvent.Type type, long waitNanos, String rejectReason, String statusIndicator, long amount) extends Record implements OperationalEvent
Per-transition event of one admission account. Admission publishes one for every hold, grant, refusal and release of every account it evaluates, the memory gate included, on whichever thread it runs; no account publishes for itself. The job snapshot travels with the admission waiter and the grant, so attribution needs no ThreadLocal.

harness/observability/OBSERVABILITY.md documents the lifecycle trace shapes, the reject-reason vocabulary and the consumer design; harness/admission/PACKAGE.md the emission rules. The message renders the transition: <name> HELD (<inUse>/<capacity>, waiters=<n>), <name> GRANTED (<inUse>/<capacity>), <name> GRANTED after <ms>ms, <name> REJECTED (<reason>), <name> RELEASED (<inUse>/<capacity>).

Since:
0.1 (2026-04-14)
Author:
Andrey Santrosyan
  • Constructor Details

    • LimiterEvent

      public LimiterEvent(JobSnapshot snapshot, Instant timestamp, String limiterName, String limiterCategory, long capacity, long inUse, int waiters, LimiterEvent.Type type, long waitNanos, String rejectReason, String statusIndicator, long amount)
      Creates an instance of a LimiterEvent record class.
      Parameters:
      snapshot - the value for the snapshot record component
      timestamp - the value for the timestamp record component
      limiterName - the value for the limiterName record component
      limiterCategory - the value for the limiterCategory record component
      capacity - the value for the capacity record component
      inUse - the value for the inUse record component
      waiters - the value for the waiters record component
      type - the value for the type record component
      waitNanos - the value for the waitNanos record component
      rejectReason - the value for the rejectReason record component
      statusIndicator - the value for the statusIndicator record component
      amount - the value for the amount record component
  • Method Details

    • message

      public String message()
      Description copied from interface: JobEvent
      Gets the message associated with this event. May provide additional context about the state change or event.
      Specified by:
      message in interface JobEvent
      Returns:
      the event message, may be null
    • 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. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      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.
    • snapshot

      public JobSnapshot snapshot()
      Returns the value of the snapshot record component.
      Specified by:
      snapshot in interface JobEvent
      Returns:
      the value of the snapshot record component
    • timestamp

      public Instant timestamp()
      Returns the value of the timestamp record component.
      Specified by:
      timestamp in interface JobEvent
      Returns:
      the value of the timestamp record component
    • limiterName

      public String limiterName()
      Returns the value of the limiterName record component.
      Returns:
      the value of the limiterName record component
    • limiterCategory

      public String limiterCategory()
      Returns the value of the limiterCategory record component.
      Returns:
      the value of the limiterCategory record component
    • capacity

      public long capacity()
      Returns the value of the capacity record component.
      Returns:
      the value of the capacity record component
    • inUse

      public long inUse()
      Returns the value of the inUse record component.
      Returns:
      the value of the inUse record component
    • waiters

      public int waiters()
      Returns the value of the waiters record component.
      Returns:
      the value of the waiters record component
    • type

      public LimiterEvent.Type type()
      Returns the value of the type record component.
      Returns:
      the value of the type record component
    • waitNanos

      public long waitNanos()
      Returns the value of the waitNanos record component.
      Returns:
      the value of the waitNanos record component
    • rejectReason

      public String rejectReason()
      Returns the value of the rejectReason record component.
      Returns:
      the value of the rejectReason record component
    • statusIndicator

      public String statusIndicator()
      Returns the value of the statusIndicator record component.
      Returns:
      the value of the statusIndicator record component
    • amount

      public long amount()
      Returns the value of the amount record component.
      Returns:
      the value of the amount record component