ddd356 / docker_broker

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

docker_broker

Build and start docker container with:

docker-compose up --build

Wait initialization. When it's done you will see a message " * Running on http://127.0.0.1:5000" image

Test a server with a Curl from container CLI.

Curl requests will return you a transaction ID.

  1. Put 1000.0 credits on to a client's account with id 1
curl "http://127.0.0.1:5000/1/1000.0/put"
  1. Withdraw 600.0 credits from the same client
curl "http://127.0.0.1:5000/1/600.0/withdraw"
  1. Try to withdraw another 600.0 credits from the same client
curl "http://127.0.0.1:5000/1/600.0/withdraw"

The last request will be cancelled because of low credits.

Look at result in a Postgre database

Use db's container CLI.

  1. Connect to the database
psql postgres://postgres:pg@localhost:5432/accounts
  1. Look at the history table
SELECT * FROM history;

image

There are two successfull transactions and one cancelled.

  1. Look at the accounts table
SELECT * FROM accounts;

image

There are 400 credits on the account of a client with ID=1.

About


Languages

Language:Python 95.1%Language:Dockerfile 4.9%