Here you can find a neat example of a microservices' architecture with C programming language.
Also following libraries are used:
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
.
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"}'