Skip to content

a snake and a c that is sharp of mind using a rabbit queue to store cards but it was filled with rust

Notifications You must be signed in to change notification settings

CanaanGM/Exp-1_DDD

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Experiment the first

contrary to popular believe DDD is not DomainDrivenDesign. . . at least not in this case, it is this: D/D/D

the way this goes is

  • CardDispenser -> sends card info to YuGiOh-Card-Queue rabbitMQ bus thru the default exchange,
  • CardProcessor <- Read the card data from YuGiOh-Card-Queue
  • CardProcessor -- process the card
  • CardProcessor -> Sends the processed cards to YuGiOh-Processed-Queue
  • Card_Saver <- Reads from YuGiOh-Processed-Queue
  • Card_Saver -- saves the cards into postgres db

you have yugioh cards in a file which u got from: YgoProDeck ; get the cards like this and don't annoy their api

http GET https://db.ygoprodeck.com/api/v7/cardinfo.php > AllCards.json

if u don't have httpie install it via python,scoop or package manager


i was sick and bored so my tired brain came up with this, it serves no practical purpose, think of it as an experiment

card info gotten from Ygoprodeck.com, i got all the cards as to not annoy their API


Run

  1. get RabbitMQ started:
docker run --hostname YuGiOh-rabbit  --name yugioh-bus -p 5672:5672 -p 15672:15672 rabbitmq:3-management

5672: to access the node 15672: to access the web interface

  1. start pubing the cards
cd cardDispenser
python -m venv venv
.\venv\Scripts\activate # source venv/bin/activate
pip install -r reqs.txt

uvicorn main:app --reload -p 4444 # or whatever u want
  1. run the c# code

  2. save the cards from the queueueueue to the database a. i. start a postgress instance docker container run -p 5432:5432 --name testgres postgres i. make sure it's correctly sat up either by dbeaver or thru the terminal i. docker exec -it <container name (docker ps helps)> psql -U admin b. cd into card_saver -> cargo build -> cargo run

Starring

  1. FastAPI as pythonAPI that will keep pumping RAW card info as JSON into rabbitMQ queueName=YuGiOh-Card-Queue, it has 2 endpoints:
    1. Start. /start. ; will start populating the que
    2. Stop. /stop; will cease hostilites and declare peace. . . .

the way the inital plan was for the API to get either a start or stop commands via REST and ivoke an event depending, at least that was the main idea, toggle switching, but as the data we have is finite, i didnt want duplication hence the way i did it.

  1. RabbitMQ as the bus that will distribute the info between the apps

  2. C# 7 as the cards proccessor, it takes the card from pyPi and removes some props and throws it again at the space rabbit this time onto a different queue queueName=YuGiOh-Processed-Queue

  3. rust as the database manager

  4. postgress as the DB

  5. Docker as the rich guy that provided the places to act

I would love to thank:

  • Panadol for making me see ghosts
  • lemon and honey
  • windows for not crashing randomly
  • git for saving me from windows

the loop is pointless as this should just run once and only once, if this was supposed to listen infinitly it should invoke events or something anyways i'm having fun used raw sql cause it's healthier than an ORM (you don't know what they put in there)

Resources

  1. turn Json to language
  2. RabbitMq c# docs
  3. RabbitMq python docs
  4. python events package
  5. this to read queue size
  6. microsoft json docs
  7. rust by example
  8. postgres docs

About

a snake and a c that is sharp of mind using a rabbit queue to store cards but it was filled with rust

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published