Class ExecutionContext

java.lang.Object
com.jsgalactic.axiom.execution.ExecutionContext

public final class ExecutionContext extends Object
Immutable request identity and monotonic deadline; safe to share with application tasks.
  • Method Details

    • create

      public static ExecutionContext create(Duration timeout)
      Creates a fresh identity and starts a deadline using the monotonic system clock.
      Parameters:
      timeout - positive budget, at most one day
      Returns:
      execution metadata
      Throws:
      IllegalArgumentException - for an invalid budget
    • requestId

      public String requestId()
      Returns a framework-generated identity; client headers cannot choose it. The identity is a random per-process prefix (16 URL-safe Base64 characters) followed by - and a hexadecimal sequence number. It is unique within the process and, with overwhelming probability, across processes. The prefix cannot be guessed without seeing an identity, but anyone who has seen one can predict later identities from the same process, so it is a correlation value and must never be used as a secret or credential.
      Returns:
      unique request identifier
    • remainingTime

      public Duration remainingTime()
      Returns the remaining budget, clamped at zero after expiry.
      Returns:
      remaining monotonic duration
    • extendDeadline

      public void extendDeadline(Duration remaining)
      Gives the request more time: the deadline becomes remaining from now if that is later than the current one, and is left alone otherwise, so it can never shorten a deadline. The runtime calls it when the head of a streamed response has been sent, to give the stream the lifetime its response asks for (see Response.withStreamLifetime); applications should use that instead. Has no effect on a deadline that has already passed, which stays expired.
      Parameters:
      remaining - positive, at most one day
      Throws:
      IllegalArgumentException - for an invalid budget
    • isDeadlineExtended

      public boolean isDeadlineExtended()
      Reports whether extendDeadline(java.time.Duration) replaced the original budget, so that a timer armed for the original deadline knows to wait for the new one.
      Returns:
      true after a successful extension
    • isExpired

      public boolean isExpired()
      Reports whether the deadline has elapsed.
      Returns:
      true once no budget remains