#restful #rest #http #web #http-api

long-running-task

Handle long-running tasks for your RESTful HTTP API

2 releases

0.1.1 Apr 29, 2024
0.1.0 Apr 29, 2024

#348 in HTTP server

Download history 273/week @ 2024-04-29

273 downloads per month

MIT/Apache

10KB
162 lines

long-running-task

A simple library to handle long-running tasks.

Why?

When exposing RESTful HTTP API paths to clients which trigger slow and/or computationally expensive operations it is best practice to make use of the long-running task concept.

When making use of this concept a single endpoint, which blocks until the operation is completed, is replaced with two endpoints. The first endpoint is used start the task. The second endpoint is used to get the state of the running task. It may be in progress (Pending) or may be completed (Done).

This crate helps to manage and keep track of long-running tasks.

Features

  • Manage and keep track of the progress of tasks and their results
  • Enable the serde feature to make tasks serialisable and use them in combination with a web-frameworks
  • Configure a lifespan to prevent completed tasks from living on indefinitely if they are not retrieved

Get started

Take a look at the Rocket example to learn how to design REST API endpoints for long-running tasks.

Dependencies

~195–385KB