Public Repository

Last pushed: a year ago
Short Description
Image providing a Celery worker and an HTTP REST API to post tasks and fetch results
Full Description

This image provides a Celery worker and an HTTP REST API to post tasks and fetch results.
You can use it as an example to setup an API / broker / worker / backend architecture.

The idea is pretty simple:

  • You post tasks through an HTTP REST API
  • the tasks are sent to workers through a broker
  • the tasks are then executed by one of the worker listening to the broker
  • once the task is executed (or has failed) its result is stored into a backend

Prerequisite:
You need to have a broker (redis/rabbitmq/etc) and a backend (redis/MySQL/PostgreSQL/etc) accessible from the API/worker containers

To launch the API, use the following command:

$ docker run -it \
    -e CELERY_RESULT_BACKEND=<backend_uri> \
    -e CELERY_BROKER_URL=<broker_uri> 
    brouberol/ovh-containers-demo api

To launch the celery worker, use the following command:

$ docker run -it \
    -e CELERY_RESULT_BACKEND=<backend_uri> \
    -e CELERY_BROKER_URL=<broker_uri> 
    brouberol/ovh-containers-demo celery_worker

You can now send tasks to the worker through the API, and query their result

$ curl -X POST http://<host>:6000/tasks
{
  "task_id": "fe1aa4f2-46ee-4c10-9a17-f7327477620d"
}
$ curl http://<host>:5000/tasks/00addf51-cc7e-427a-b20b-0499b73ded1a
{
  "children": [], 
  "result": 54, 
  "status": "SUCCESS", 
  "traceback": null
}
Docker Pull Command
Owner
brouberol

Comments (0)