Record Class MailboxConfig

java.lang.Object
java.lang.Record
dev.agenor.core.mailbox.MailboxConfig
Record Components:
capacity - maximum number of messages held before overflowPolicy applies; must be positive
overflowPolicy - what to do with a message arriving at a full mailbox; must not be null
maxConcurrentHandlers - how many of this agent's handlers may run at once; must be positive. This is the bound that matters: the queue only fills once handlers are saturated, so it is the constraint the capacity sits behind (ADR-033 D-2)

public record MailboxConfig(int capacity, OverflowPolicy overflowPolicy, int maxConcurrentHandlers) extends Record
Bounds and overflow behaviour for one agent's mailbox.
Since:
0.27.0
  • Field Details

    • DEFAULT_CAPACITY

      public static final int DEFAULT_CAPACITY
      Capacity used by defaults().
      See Also:
    • DEFAULT_MAX_CONCURRENT_HANDLERS

      public static final int DEFAULT_MAX_CONCURRENT_HANDLERS
      Concurrent handler limit used by defaults(). High enough that an ordinary agent never meets it, low enough that one slow handler cannot spawn threads without limit.
      See Also:
  • Constructor Details

    • MailboxConfig

      public MailboxConfig(int capacity, OverflowPolicy overflowPolicy, int maxConcurrentHandlers)
      Validates the configuration.
      Throws:
      IllegalArgumentException - if capacity or maxConcurrentHandlers is not positive
      NullPointerException - if overflowPolicy is null
    • MailboxConfig

      public MailboxConfig(int capacity, OverflowPolicy overflowPolicy)
      Creates a configuration with the default concurrent-handler limit.
      Parameters:
      capacity - maximum number of messages held before overflowPolicy applies
      overflowPolicy - what to do with a message arriving at a full mailbox
  • Method Details

    • defaults

      public static MailboxConfig defaults()
      Returns the default configuration: 1024 messages, dropping the oldest on overflow.
      Returns:
      a non-null default configuration
    • 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 '=='.
      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.
    • capacity

      public int capacity()
      Returns the value of the capacity record component.
      Returns:
      the value of the capacity record component
    • overflowPolicy

      public OverflowPolicy overflowPolicy()
      Returns the value of the overflowPolicy record component.
      Returns:
      the value of the overflowPolicy record component
    • maxConcurrentHandlers

      public int maxConcurrentHandlers()
      Returns the value of the maxConcurrentHandlers record component.
      Returns:
      the value of the maxConcurrentHandlers record component