Record Class StreamPolicy

java.lang.Object
java.lang.Record
com.jsgalactic.axiom.execution.StreamPolicy
Record Components:
maxActive - maximum number of concurrently active streams

public record StreamPolicy(int maxActive) extends Record
Immutable bound on the streams that may run at the same time. Each stream holds one slot from the moment its response head is accepted until its body ends, is cancelled or is cut by shutdown. The bound is separate from request admission: a stream leaves its request slot when it becomes a stream, so open streams cannot take capacity away from ordinary requests. An aggregate bound applies to every listener or test client, and a route override narrows it for that route. A new stream is refused with 503 when either bound is full, before any stream bytes are written.
  • Constructor Summary

    Constructors
    Constructor
    Description
    StreamPolicy(int maxActive)
    Validates the bound before it can be installed.
  • Method Summary

    Modifier and Type
    Method
    Description
    final boolean
    Indicates whether some other object is "equal to" this one.
    final int
    Returns a hash code value for this object.
    int
    Returns the value of the maxActive record component.
    reject(int maxActive)
    Configures immediate refusal when the active limit is occupied.
    final String
    Returns a string representation of this record class.

    Methods inherited from class java.lang.Object

    clone, finalize, getClass, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • StreamPolicy

      public StreamPolicy(int maxActive)
      Validates the bound before it can be installed.
      Parameters:
      maxActive - positive active limit
      Throws:
      IllegalArgumentException - if the limit is not positive
  • Method Details

    • reject

      public static StreamPolicy reject(int maxActive)
      Configures immediate refusal when the active limit is occupied.
      Parameters:
      maxActive - positive active limit
      Returns:
      policy that refuses a new stream with 503 when all slots are taken
    • 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 '=='.
      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.
    • maxActive

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