---
title: "HTTP Task manager | wasmCloud"
description: "This web component tracks and updates information about asynchronous tasks, backed by a Postgres Database."
canonical: "https://wasmcloud.com/docs/v1/examples/rust/component/http-task-manager/"
---

This is documentation for wasmCloud **v1**, which is no longer actively maintained.

For up-to-date documentation, see the **[latest version](https://wasmcloud.com/docs/)** (v2).

Version: v1

# HTTP Task manager

This web component tracks and updates information about asynchronous tasks, backed by a [Postgres](https://www.postgresql.org/) Database.

Clients can make HTTP requests to endpoints like the following:

| Endpoint | Description |
| --- | --- |
| `GET /tasks` | List ongoing tasks |
| `POST /tasks/:id/status` | Get status of a specific task |
| `POST /tasks` | Submit a new task |

Tasks can also be submitted over the wasmCloud Lattice (i.e. [via wRPC](https://wasmcloud.com/docs/v1/reference/glossary/#wrpc)), rather than simply via HTTP.

## Architecture

This application requires a few other pieces to function:

- [wasmCloud HTTP server](https://github.com/wasmCloud/wasmCloud/tree/main/crates/provider-http-server) for receiving incoming HTTP requests
- [wasmCloud SQLDB Postgres Provider](https://github.com/wasmCloud/wasmCloud/tree/main/crates/provider-sqldb-postgres) for persistence of tasks

## Prerequisites

- `cargo` >= 1.81
- [`wash`](https://wasmcloud.com/docs/v1/installation/) >=0.30.0
- `docker` (or some other means to easily run Postgres instances)

## Build

You can build the HTTP task manager component with the [WAsmcloud SHell `wash`](https://wasmcloud.com/docs/v1/cli/):

console

```console
wash build
```

Note that if you'd like to build with `cargo` you need to specify the `--target` option:

console

```console
cargo build --target=wasm32-wasip1
```

## Launch

### Start dependencies

As the application depends on a Postgres instance for persistence, let's start an ephemeral one:

console

```console
docker run \
    --rm \
    -p 5432:5432 \
    -e POSTGRES_PASSWORD=postgres \
    --name pg \
    postgres:16-alpine
```

### Start the application

Now, we're ready to start our component along with the required providers.

First we start a new wasmCloud host:

console

```console
wash up
```

> \[!NOTE\] This command won't return, so run open a new terminal to continue running commands

To enable our application we'll start to *connect* to Postgres requires setting up some configuration with `wash`:

console

```console
wash config put default-postgres \
    POSTGRES_HOST=localhost \
    POSTGRES_PORT=5432 \
    POSTGRES_USERNAME=postgres \
    POSTGRES_PASSWORD=postgres \
    POSTGRES_DATABASE=postgres \
    POSTGRES_TLS_REQUIRED=false
```

> \[!NOTE\] In production, you'll want to use wasmCloud secrets to set up the required configuration.
>
> See [wasmCloud documentation for secrets](https://wasmcloud.com/docs/v1/concepts/secrets/)

Next, we deploy our application:

console

```console
wash app deploy ./local.wadm.yaml
```

We can confirm that the application was deployed successfully:

console

```console
wash app list
```

Once the application reports as **Deployed** in the application list, you can use `curl` to send a request to the running HTTP server.

We'll hit the `/ready` endpoint:

console

```console
curl localhost:8000/ready
```

You should receive output like the following:

```
{"status":"success"}
```

### Migrating the database

Since this application uses a database, we must migrate the database that uses it. For relative ease of use, the application has been written such that it can migrate it's *own* database (and migrations are written idempotently).

While normally a separate component (or manual DB administrator action) would trigger migrations, we can trigger a migration via HTTP:

console

```console
curl -X \
    POST -H "Content-Type: application/json; charset=utf8" \
    localhost:8000/admin/v1/db/migrate
```

Regardless of how many times you run the migration, you should receive the output below:

```
{"status":"success"}
```

### Adding a new task

To try out adding a new task we can use `curl`:

console

```console
curl \
    -X POST \
    -H "Content-Type: application/json; charset=utf8" \
    localhost:8000/api/v1/tasks \
    --data '{"group_id": "test", "task_data": {"one":1}}'
```

### Getting a list of existing tasks

To retrieve all existing tasks:

console

```console
curl localhost:8000/api/v1/tasks
```

> \[!NOTE\] If you have `jq` installed, this would be a great time to use it!

## Tests

You can run the full E2E test suite:

console

```console
cargo test
```

Last updated on **Nov 20, 2026** by **Victor Adossi**
