Class RPCResult<O>

java.lang.Object
io.superdurable.dex.RPCResult<O>
Type Parameters:
O - the concrete Java RPC output type

public final class RPCResult<O> extends Object
Carries a typed RPC output, optional next-Step movements, and Step type cancellation.

Return this value from a function-style RPC method. The output is encoded according to the RPC method's declared generic return type, while movements let an RPC start or advance Flow execution atomically with its state changes.

@RPC
public RPCResult<OrderStatus> approve(Context context, Approval input) {
    return RPCResult.of(OrderStatus.APPROVED, StepMovement.of(ShipOrder.class, input.order))
            .withCancelingSteps(QuoteCarrier.class, ApprovalTimeout.class);
}
  • Method Details

    • of

      public static <O> RPCResult<O> of(O output)
      Creates an RPC result without next Steps.
      Type Parameters:
      O - the output type
      Parameters:
      output - the typed RPC output, which may be null
      Returns:
      the RPC result
    • of

      public static <O> RPCResult<O> of(O output, StepMovement<?>... nextSteps)
      Creates an RPC result that also schedules next Steps.
      Type Parameters:
      O - the output type
      Parameters:
      output - the typed RPC output, which may be null
      nextSteps - the movements to schedule
      Returns:
      the RPC result
    • withCancelingSteps

      public RPCResult<O> withCancelingSteps(Class<? extends Step<?>>... stepClasses)
      Cancels queued or active executions of the selected Step types in the current Flow.

      Dex resolves the selection after this RPC's Attribute and Channel writes commit and before this result's next-Step movements are enqueued. Existing executions that already finished, were canceled, or do not exist are ignored. Dex interrupts a selected Java handler when cancellation reaches its Worker and continues with this result's next Steps without waiting for that handler to return.

      Repeated calls take the union of their arguments. Each argument must be a Step class registered with the current Flow; a null or external Step class causes an invalid RPC result. RPC results cannot select sibling executions because separate invocations do not share an invocation-scoped Step execution lineage.

      Parameters:
      stepClasses - registered Step classes whose queued or active executions should be canceled
      Returns:
      a new RPC result containing the combined cancellation selection