This multirepo has a few Python projects. These projects are detailed below. This project can be used for testing purposes and POC.
Contained projects are simple in purpose. These projects must not be used as project templates.
Table of Contents
The celery_tasks project has defined 3 simple example task for testing. This tasks are:
- Concatenate 2 or 3 strings.
- Calculate the exponential of a number.
- Calculate the square root of a number.
These tasks have an active wait function that depends on an environment variable called TASK_ARTIFICIAL_DELAY.
With a periodic time defined by the environment variable CRON_TASK_DELAY, this project call a task automatically.
This task is a simple print with the content of the environment variable.
To use the tasks defined fro this celery app, a REST API was implemented. This API have the following endpoints:
- POST /call_task -> This endpoint can invoke one of the tasks defined in
celery_tasksby the following structure:{ "task_name": "sqrt", "parameters": [ 4 ] } - GET /task/{task_id} -> Recover the status and the result of the task with that ID.
- GET /health-check -> Returns a dummy JSON with the state of the server.
All this projects can be deployed by the command
docker compose up
# or
docker compose up --buildThis file contains services for:
- The broker (rabbitmq).
- The backend (redis).
- The celery worker for tasks.
- The celery worker for cron tasks.
- The REST API, exposed in port 8000.
- The flower server, exposed in port 5556.
All the necessary environment variables will be allocated in the
.envfile.
There is a functional celery example in folder _experimental/celery_poc.
This folder can be used for celery testing purposes.