Package com.jsgalactic.axiom.execution
Class ExecutionContext
java.lang.Object
com.jsgalactic.axiom.execution.ExecutionContext
Immutable request identity and monotonic deadline; safe to share with application tasks.
-
Method Summary
Modifier and TypeMethodDescriptionstatic ExecutionContextCreates a fresh identity and starts a deadline using the monotonic system clock.voidextendDeadline(Duration remaining) Gives the request more time: the deadline becomesremainingfrom now if that is later than the current one, and is left alone otherwise, so it can never shorten a deadline.booleanReports whetherextendDeadline(java.time.Duration)replaced the original budget, so that a timer armed for the original deadline knows to wait for the new one.booleanReports whether the deadline has elapsed.Returns the remaining budget, clamped at zero after expiry.Returns a framework-generated identity; client headers cannot choose it.
-
Method Details
-
create
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
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
Returns the remaining budget, clamped at zero after expiry.- Returns:
- remaining monotonic duration
-
extendDeadline
Gives the request more time: the deadline becomesremainingfrom 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 (seeResponse.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 whetherextendDeadline(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
-