durable-execution - v0.7.0
    Preparing search index...

    Type Alias DurableTaskOptions<TInput, TOutput>

    DurableTaskOptions: DurableTaskCommonOptions & {
        run: (
            ctx: DurableTaskRunContext,
            input: TInput,
        ) => TOutput | Promise<TOutput>;
    }

    Options for a durable task that can be run using a durable executor. A task is resilient to task failures, process failures, network connectivity issues, and other transient errors. The task should be idempotent as it may be run multiple times if there is a process failure or if the task is retried.

    When enqueued with an executor, a DurableTaskHandle is returned. It supports getting the execution status, waiting for the task to complete, and cancelling the task.

    The output of the run function is the output of the task.

    The input and output are serialized and deserialized using the serializer passed to the durable executor.

    Make sure the id is unique among all the durable tasks in the same durable executor. If two tasks are registered with the same id, the second one will overwrite the first one, even if the first one is enqueued.

    The tasks can be added to an executor using the DurableExecutor.task method. If the input to a task needs to be validated, it can be done using the DurableExecutor.validateInput or DurableExecutor.inputSchema methods.

    See the task examples section for more details on creating tasks.

    Type Parameters

    • TInput = unknown
    • TOutput = unknown

    Type declaration

    • run: (ctx: DurableTaskRunContext, input: TInput) => TOutput | Promise<TOutput>

      The task run logic. It returns the output.

      Behavior on throwing errors:

      • If the task throws an error or a {@link DurableTaskError}, the task will be marked as failed
      • If the task throws a {@link DurableTaskTimedOutError}, it will be marked as timed out
      • If the task throws a {@link DurableTaskCancelledError}, it will be marked as cancelled
      • Failed and timed out tasks might be retried based on the task's retry configuration
      • Cancelled tasks will not be retried
    const extractFileTitle = executor
    .inputSchema(v.object({ filePath: v.string() }))
    .task({
    id: 'extractFileTitle',
    timeoutMs: 30_000, // 30 seconds
    run: async (ctx, input) => {
    // ... extract the file title
    return {
    title: 'File Title',
    }
    },
    })