Skip to content

Test environment for a simple queuing system using redis and fastapi

Notifications You must be signed in to change notification settings

gcanahuirev/fastapi-redis

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple queuing system with redis

Requirements

  • Python >= 3.11
  • Poetry package manager
  • Redis instance up and running
  • Curl or any http client

Installation

  1. Add the .env file and install dependencies
poetry config virtualenvs.in-project = true
poetry install
  1. Activate virtual env for python
poetry shell
  1. See the scripts available at pyproject.toml file
  2. Check redis instance up and use a redis cli or gui
  3. If you want deactivate venv python run
deactivate

Use cases

Queue system with fastapi

  • Run the producer script, then view data in redis
poe start_msg_pub
  • Finally run the consumer script
poe start_msg_sub

Queue system without fastapi

  • Run the fastapi server,
poe dev

then run the request, where 5 and 8 are the input values

curl -X POST localhost:8000/job -H "Content-Type: application/json" -d '{"lowest": 5, "highest": 8}'
  • Finally run the consumer script
poe start_num_sub

NOTE: You can change the amount of test data in src/producer/msg.py, where 30 is amount and 1 the delay in seconds

if __name__ == "__main__":
    main(10, 1)

About

Test environment for a simple queuing system using redis and fastapi

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages