Package dev.agenor.core.mailbox
Record Class MailboxConfig
java.lang.Object
java.lang.Record
dev.agenor.core.mailbox.MailboxConfig
- Record Components:
capacity- maximum number of messages held beforeoverflowPolicyapplies; must be positiveoverflowPolicy- what to do with a message arriving at a full mailbox; must not benullmaxConcurrentHandlers- 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 Summary
FieldsModifier and TypeFieldDescriptionstatic final intCapacity used bydefaults().static final intConcurrent handler limit used bydefaults(). -
Constructor Summary
ConstructorsConstructorDescriptionMailboxConfig(int capacity, OverflowPolicy overflowPolicy) Creates a configuration with the default concurrent-handler limit.MailboxConfig(int capacity, OverflowPolicy overflowPolicy, int maxConcurrentHandlers) Validates the configuration. -
Method Summary
Modifier and TypeMethodDescriptionintcapacity()Returns the value of thecapacityrecord component.static MailboxConfigdefaults()Returns the default configuration: 1024 messages, dropping the oldest on overflow.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.intReturns the value of themaxConcurrentHandlersrecord component.Returns the value of theoverflowPolicyrecord component.final StringtoString()Returns a string representation of this record class.
-
Field Details
-
DEFAULT_CAPACITY
public static final int DEFAULT_CAPACITYCapacity used bydefaults().- See Also:
-
DEFAULT_MAX_CONCURRENT_HANDLERS
public static final int DEFAULT_MAX_CONCURRENT_HANDLERSConcurrent handler limit used bydefaults(). 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
Validates the configuration.- Throws:
IllegalArgumentException- ifcapacityormaxConcurrentHandlersis not positiveNullPointerException- ifoverflowPolicyisnull
-
MailboxConfig
Creates a configuration with the default concurrent-handler limit.- Parameters:
capacity- maximum number of messages held beforeoverflowPolicyappliesoverflowPolicy- what to do with a message arriving at a full mailbox
-
-
Method Details
-
defaults
Returns the default configuration: 1024 messages, dropping the oldest on overflow.- Returns:
- a non-null default configuration
-
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. -
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. -
equals
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 withObjects::equals(Object,Object); primitive components are compared with '=='. -
capacity
public int capacity()Returns the value of thecapacityrecord component.- Returns:
- the value of the
capacityrecord component
-
overflowPolicy
Returns the value of theoverflowPolicyrecord component.- Returns:
- the value of the
overflowPolicyrecord component
-
maxConcurrentHandlers
public int maxConcurrentHandlers()Returns the value of themaxConcurrentHandlersrecord component.- Returns:
- the value of the
maxConcurrentHandlersrecord component
-