nexus-rpc
    Preparing search index...

    Interface OperationHandler<I, O>Experimental

    A handler for a Nexus operation.

    This interface is meant to be implemented by Nexus service implementors.

    interface OperationHandler<I, O> {
        cancel(ctx: OperationContext, token: string): Promise<void>;
        getInfo(ctx: OperationContext, token: string): Promise<OperationInfo>;
        getResult(ctx: GetOperationResultContext, token: string): Promise<O>;
        start(
            ctx: StartOperationContext,
            input: I,
        ): Promise<HandlerStartOperationResult<O>>;
    }

    Type Parameters

    • I
    • O
    Index

    Methods

    • Experimental

      Handle requests to cancel an asynchronous operation.

      Cancelation of a Nexus operation is:

      1. asynchronous - returning from this method only confirms that cancelation was notified; the implementation may however choose to process the cancellation at a later time, or to ignore it entirely.
      2. idempotent - implementations must ignore duplicate cancelations for the same operation.

      Parameters

      Returns Promise<void>

    • Experimental

      Handle requests to get the result of an asynchronous operation. Return non error result to respond successfully inline, or throw an OperationStillRunningError to indicate that an asynchronous operation is still running.

      Throw an OperationError to indicate that an operation completed as failed or canceled.

      When timeoutMs is greater than zero, this request should be treated as a long poll. Note that the specified wait duration may be longer than the configured client or server side request timeout, and should be handled separately.

      It is the implementor's responsibility to respect the client's timeout duration and return in a timely fashion, leaving enough time for the request to complete and the response to be sent back.

      Parameters

      Returns Promise<O>