Skip to content

[TRI-1362] docs: Add better documentation for how to use Task Callbacks #553

@ericallam

Description

@ericallam

We currently only have a small amount of documentation for task callbacks in the io.runTask() docs but it would be great to flesh out the documentation in more detail, especially usage with just io.runTask instead of io.replicate.runTask, e.g.:

await io.runTask(
  "use-callback-url",
  async (task) => {
    // task.callbackUrl is the URL to call when the task is done
    // The output of this task will be the body POSTed to this URL
  },
  {
    name: "Use the callbackUrl to notify the caller when the task is done",
    callback: {
      enabled: true,
      timeoutInSeconds: 300, // If task.callbackUrl is not called within 300 seconds, the task will fail
    },
  }
);

Things the doc should cover:

  • When it makes sense to use callback URLs (a callback from an external system). Would be great to find another example of this other than Replicate
  • How to correctly type runTask so the output type is correct
  • How the request to the task URL works (POST and the entire JSON body becomes the task output)
  • How the timeout works

I think this would probably best live in Documentation -> Guides -> Task Callbacks

TRI-1362

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions