Interface CapacityLimiter.Ticket

Enclosing interface:
CapacityLimiter

public static interface CapacityLimiter.Ticket
Result of CapacityLimiter.tryAcquire(Classification, ContextMap) when capacity is enough to meet the demand. A CapacityLimiter.Ticket can terminate when either one of the following occurs:
  • When the request is successfully completed completed()
  • When the request fails due to an external capacity rejection i.e., dropped dropped()
  • When the request fails due to a local errorfailed(Throwable)
  • When the request is cancelled ignored()
  • Method Summary

    Modifier and Type
    Method
    Description
    int
    Callback to indicate that a request was completed successfully.
    int
    Callback to indicate that a request was dropped externally (e.g.
    int
    Callback to indicate that a request has failed.
    int
    Callback to indicate that a request had not a capacity deterministic termination.
    Representation of the state of the CapacityLimiter when this CapacityLimiter.Ticket was issued.
  • Method Details

    • state

      Representation of the state of the CapacityLimiter when this CapacityLimiter.Ticket was issued.
      Returns:
      the state of the limiter at the time this CapacityLimiter.Ticket was issued.
    • completed

      int completed()
      Callback to indicate that a request was completed successfully.
      Returns:
      An integer as hint (if positive), that represents an estimated remaining capacity after this ticket's terminal callback. If supported, a positive number means there is capacity. Otherwise, a negative value is returned.
    • dropped

      int dropped()
      Callback to indicate that a request was dropped externally (e.g. peer rejection) due to capacity issues.

      Note that loss-based algorithms tend to reduce the limit by a multiplier on such events.

      Returns:
      An integer as hint (if positive), that represents an estimated remaining capacity after this ticket's terminal callback. If supported, a positive number means there is capacity. Otherwise, a negative value is returned.
    • failed

      int failed(Throwable error)
      Callback to indicate that a request has failed.

      Algorithms may choose to act upon failures (i.e. Circuit Breaking).

      Parameters:
      error - the failure cause.
      Returns:
      An integer as hint (if positive), that represents an estimated remaining capacity after this ticket's terminal callback. If supported, a positive number means there is capacity. Otherwise, a negative value is returned.
    • ignored

      int ignored()
      Callback to indicate that a request had not a capacity deterministic termination.

      Ignoring a CapacityLimiter.Ticket is a way to indicate to the CapacityLimiter that this operation's termination should not be considered towards a decision for modifying the limits. e.g., An algorithm that measures delays (time start - time end), can use that to ignore a particular result from the feedback loop.

      Returns:
      An integer as hint (if positive), that represents an estimated remaining capacity after this ticket's terminal callback. If supported, a positive number means there is capacity. Otherwise, a negative value is returned.