Class BlueMindCallBudget

java.lang.Object
org.exoplatform.bluemind.client.BlueMindCallBudget
All Implemented Interfaces:
AutoCloseable

public final class BlueMindCallBudget extends Object implements AutoCloseable
One overall time budget for the BlueMind calls made on one thread, set by a caller whose own time is bounded — a landing of a mail's invitation, which holds the user's click: every exchange BlueMindRestClient sends while it is open waits the smaller of the client's request timeout and the time left, and none is sent once nothing is left. The wait covers the whole exchange, body included.

Opened with start(java.time.Duration), closed with close() — a try-with-resources — and per thread: a call made on another thread is not bounded by it. Opening one inside another keeps the earlier end when it is the sooner.

  • Method Details

    • start

      public static BlueMindCallBudget start(Duration budget)
      Opens a budget on the current thread.
      Parameters:
      budget - the time the calls made until close() may take altogether; null or negative is none left
      Returns:
      the budget, to close
    • close

      public void close()
      Closes the budget: the thread's previous one, if any, applies again.
      Specified by:
      close in interface AutoCloseable