Skip to content

Redis Queue project is aimed at creating a queue based in redis and celery using redis data structures.

License

Notifications You must be signed in to change notification settings

idris-rampurawala/redis-queue

Repository files navigation

Redis Queue

The MIT License

Redis Queue project is aimed at creating a queue based in redis and celery using redis data structures. We can control the task concurrency as per our need

Note: This project is forked from one of my project Flask Boilerplate to quickly get started.

Contributing

We encourage you to contribute to this project! Please check out the Contributing guidelines about how to proceed.

Getting Started

Prerequisites

  • Python 3.11.3 or higher
  • Up and running Redis client

Project setup

# clone the repo
$ git clone git@github.com:idris-rampurawala/redis-queue.git
# move to the project folder
$ cd redis-queue

If you want to install redis via docker

$ docker run -d --name="redis-queue" -p 6379:6379 redis

Creating virtual environment

  • Setup the correct python version using pyenv pyenv install 3.11.3
  • Install pipenv a global python project pip install pipenv
  • Create a virtual environment for this project
    # activating the pipenv environment
    $ pipenv shell
    # install all dependencies (include -d for installing dev dependencies)
    $ pipenv install -d

Configuration

  • There are 3 configurations development, staging and production in config.py. Default is development
  • Create a .env file from .env.example and set appropriate environment variables before running the project

Running app

  • Run flask app python run.py
  • Logs would be generated under log folder

Running celery workers

  • Run redis locally before running celery worker
  • Celery worker can be started with following command
    # run following command in a separate terminal
    $ celery -A celery_worker.celery worker --loglevel='INFO'  
    # (append `--pool=solo` for windows)

Test

Test if this app has been installed correctly and it is working via following curl commands (or use in Postman)

  • Check if the app is running via status API
    $ curl --location --request GET 'http://localhost:5000/status'
  • Check if core app API and celery task is working via
    $ curl --location --request GET 'http://localhost:5000/api/v1/core/test'
  • Check if authorization is working via (change API Key as per you .env)
    $ curl --location --request GET 'http://localhost:5000/api/v1/core/restricted' --header 'x-api-key: 436236939443955C11494D448451F'
  • Push the task to queue
    curl --location 'http://127.0.0.1:5000/api/v1/core/requestor' \
      --header 'Content-Type: application/json' \
      --data '{
          "id": 1
      }'

License

This program is free software under MIT license. Please see the LICENSE file in our repository for the full text.

About

Redis Queue project is aimed at creating a queue based in redis and celery using redis data structures.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages