Record Class ExecutionBudget

java.lang.Object
java.lang.Record
com.jsgalactic.axiom.execution.ExecutionBudget
Record Components:
aggregate - bounds all executions and supplies the policy of routes without an override
routePolicies - immutable additional bounds keyed by registered route identity

public record ExecutionBudget(AdmissionPolicy aggregate, Map<Route,AdmissionPolicy> routePolicies) extends Record
Immutable application-wide execution budget. The aggregate policy bounds requests from every listener and test client of one application; a route override bounds that route in addition to the aggregate. The counters behind the budget belong to the application, so no listener has a private copy of its capacity.
  • Constructor Details

    • ExecutionBudget

      public ExecutionBudget(AdmissionPolicy aggregate, Map<Route,AdmissionPolicy> routePolicies)
      Validates the aggregate and copies the overrides into an immutable map, so later changes to a caller's map cannot change this budget.
  • Method Details

    • of

      public static ExecutionBudget of(AdmissionPolicy aggregate)
      Creates a budget with no route overrides.
      Parameters:
      aggregate - bounds all executions of the application
      Returns:
      budget whose every route uses the aggregate policy
    • defaults

      public static ExecutionBudget defaults()
      Creates the default budget: no queue, 36 active executions and no route overrides.
      Returns:
      the unchanged default budget
    • policy

      public AdmissionPolicy policy(Route route)
      Returns the policy that bounds a route: its override when present, otherwise the aggregate.
      Parameters:
      route - registered route identity
      Returns:
      effective admission policy
    • withRoute

      public ExecutionBudget withRoute(Route route, AdmissionPolicy policy)
      Returns a budget with one route bound replaced, leaving the aggregate and other overrides as they are.
      Parameters:
      route - route identity whose bound is replaced
      policy - new bound for that route
      Returns:
      a new budget; this one is unchanged
    • withoutRoute

      public ExecutionBudget withoutRoute(Route route)
      Returns a budget without the bound of one route, leaving the aggregate and other overrides as they are. Removing an override that is not present has no effect.
      Parameters:
      route - route identity whose override is removed
      Returns:
      a new budget; this one is unchanged
    • 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.
    • aggregate

      public AdmissionPolicy aggregate()
      Returns the value of the aggregate record component.
      Returns:
      the value of the aggregate record component
    • routePolicies

      public Map<Route,AdmissionPolicy> routePolicies()
      Returns the value of the routePolicies record component.
      Returns:
      the value of the routePolicies record component