@dxos/compute - v0.16.0
    Preparing search index...

    Interface DurableHandler<_Input, _Output, _Requirements, _Rpcs>

    Handler of a durable operation: the callbacks of one running process instance.

    Process lifecycle: Initial -> Running <-> Suspended -> Terminated.

    • onSpawn -> called once when the process is spawned.
    • onInput -> called for every input submitted to the process.
    • onAlarm -> called for processes scheduling alarms.
    • onChildEvent -> called when child process produces output or exits.
    interface DurableHandler<_Input, _Output, _Requirements, _Rpcs extends Rpc.Any> {
        rpcHandlers: Context<ToHandler<_Rpcs>>;
        onAlarm(): Effect<void, never, _Requirements | BaseServices>;
        onChildEvent(
            event: ChildEvent<unknown>,
        ): Effect<void, never, _Requirements | BaseServices>;
        onInput(input: _Input): Effect<void, never, _Requirements | BaseServices>;
        onSpawn(): Effect<void, never, _Requirements | BaseServices>;
    }

    Type Parameters

    • _Input
    • _Output
    • _Requirements
    • _Rpcs extends Rpc.Any
    Index

    Properties

    rpcHandlers: Context<ToHandler<_Rpcs>>

    Handlers for the RPCs provided by the process.

    Methods

    • Called when there's input available to process.

      The function can be called in parallel.

      Parameters

      Returns Effect<void, never, _Requirements | BaseServices>

      A signal indicating to the runtime whether the process is finished, or should be resumed later.

      Throwing in the handler will terminate the process with an error.

      Note: This function should aim to complete in under 5 seconds to avoid exceeding limits in serverless environments.

    • Called when the process is spawned. Not called for processes that are resumed from a previously suspended state.

      Returns Effect<void, never, _Requirements | BaseServices>

      A signal indicating to the runtime whether the process is finished, or should be resumed later.

      Throwing in the handler will terminate the process with an error.

      Note: This function should aim to complete in under 5 seconds to avoid exceeding limits in serverless environments.