Skip to content
This repository has been archived by the owner on Mar 26, 2024. It is now read-only.

Transactional microservices architecture with ZeroMQ, C, Python(Flask) and PostgreSQL

License

Notifications You must be signed in to change notification settings

fractalliter/c_microservices

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

18 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A microservice approach with C programming language

Here you can find a neat example of a microservices' architecture with C programming language.

Also following libraries are used:

  1. ZeroMQ
  2. Json Parser
  3. PostgreSQL
  4. Flask

Microservices

The solution comprises two services:

The API is just a simple Flask server which is listening on default port 5000. It's designated to hand over a POST request from client to the ZeroMQ server on port 5555. On the other side of the ZeroMQ channel it's the transaction service, which is written in C programming language, listening for coming messages.

The transaction service making a connection to PostgreSQL server, in this case test database. Transaction service is receiving a message from ZeroMQ and then commence a transactional query on the account table of test database. If user doesn't own sufficient fund the transaction will rollback.

How to run

Rename .env.example to .env then run

docker-compose up

and then send a request with enum direction{in,out}

curl -X POST localhost:5000 -d '{"user":"3","amount":"10","direction":"out"}'