Class GrpcCall

java.lang.Object
com.jsgalactic.axiom.grpc.GrpcCall

public final class GrpcCall extends Object
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 Details

    • current

      public static GrpcCall 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

      public ExecutionContext 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

      public Duration remainingTime()
      Returns the time left before the call's deadline, clamped at zero. A call with no deadline has a one-day budget, matching execution().
      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

      public void onCancel(Runnable action)
      Runs an action once when cancelled() 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