Package com.jsgalactic.axiom.grpc
Class GrpcCall
java.lang.Object
com.jsgalactic.axiom.grpc.GrpcCall
The deadline and cancellation of the gRPC call on the current thread. A generated service handler
reads it with
current(); callers that are not serving a gRPC call get an IllegalStateException. Instances belong to one call and are safe to share with the threads that
call it.-
Method Summary
Modifier and TypeMethodDescriptionbooleanReports whether the client cancelled the call or its deadline elapsed.static GrpcCallcurrent()Returns the call bound to the current thread.Returns the call's identity and original deadline budget as an Axiom execution context.voidRuns an action once whencancelled()becomes true.Returns the time left before the call's deadline, clamped at zero.
-
Method Details
-
current
Returns the call bound to the current thread.- Returns:
- the current call
- Throws:
IllegalStateException- if no gRPC call is attached to this thread
-
execution
Returns the call's identity and original deadline budget as an Axiom execution context. It is created when the call starts from the client's deadline (or one day when the client sent none), so it never extends past that deadline and reports expiry independently of later clock reads.- Returns:
- immutable execution metadata for this call
-
remainingTime
Returns the time left before the call's deadline, clamped at zero. A call with no deadline has a one-day budget, matchingexecution().- Returns:
- remaining time
-
cancelled
public boolean cancelled()Reports whether the client cancelled the call or its deadline elapsed.- Returns:
- true once the call can no longer send a result
-
onCancel
Runs an action once whencancelled()becomes true. If the call is already cancelled the action runs on the calling thread before this method returns. Actions run on whichever thread observes the cancellation, so they must be quick and thread-safe.- Parameters:
action- what to run on cancellation- Throws:
NullPointerException- if the action is null
-