Async-op is a set of RESTful API(s) for asynchronous file upload related operations. It implements start, stop, pause and terminate file upload functionalities. It has been containerized using Docker for easy portability.
- DjangoREST framework (APIs)
- Redis (Message broker)
- Celery (Task scheduler)
- PostgreSQL (Database)
- Docker and Docker-Compose (Containerizing the application)
-
File upload
http://localhost:8000/api/upload-file/
Handles POST data containing the uploaded file -
Task revoke
http://localhost:8000/api/revoke/{task_id}/
Revoked the task specified by task_id -
Task pause
http://localhost:8000/api/pause/{task_id}/
Pauses the task specified by task_id Task gets revoked if not resumed within 5 mins -
Task resume
http://localhost:8000/api/resume/{task_id}/
Resumes the paused task specified by task_id -
CSV Export
http://localhost:8000/api/export/?from_date={}&to_date={}/
Exports the database instances (i.e. form responses in the collect app context) in the range of from_date and to_date into csv -
Documentation
http://localhost:8000/docs/
Auto generated API documentation
-
Clone the repository
git clone https://github.com/salmanahmed404/async-op.git
-
Create and activate virtual environment
virtualenv --python=python3 venv #or any name source venv/bin/activate
-
Navigate to project code
cd project
-
Install packages
pip install -r requirements.txt
-
Database setup
- Ensure you have postgres installed otherwise install using package manager
sudo apt-get install postgresql
- Create database under the default postgres user
sudo su postgres psql CREATE DATABASE atlan_collect;
- Ensure you have postgres installed otherwise install using package manager
-
Run the migrations
python manage.py migrate
-
Prepare test data (optional)
mkdir data python generate_dummy_data.py
The script accepts command line arguments specifying the number of records in the resulting csv file. If not provided it defaults to 20000
-
Make directory (for storing the exported csv files)
mkdir exports
-
Run the development server
python manage.py runserver
-
Clone the repository
git clone [repository_url]
-
Build and run
docker-compose up --build