1
0
mirror of https://github.com/ebosas/microservices.git synced 2025-02-10 18:30:53 +02:00
2021-06-01 21:38:22 +03:00
2021-06-01 14:31:49 +03:00
2021-06-01 14:26:02 +03:00
2021-06-01 15:00:59 +03:00
2021-06-01 14:31:49 +03:00
2021-06-01 14:26:02 +03:00
2021-06-01 14:31:49 +03:00
2021-06-01 14:26:02 +03:00
2021-06-01 15:00:59 +03:00
2021-06-01 14:26:02 +03:00
2021-06-01 09:03:48 +03:00
2021-06-01 21:38:22 +03:00

Microservices

A basic example of microservice architecture which demonstrates communication between a few loosely coupled services. This includes messages between a server terminal and a web user interface with a database service in the middle.

Written in Go, this mainly showcases the exchange of information using RabbitMQ—between backend services—and WebSocket—between frontend and backend.

The services are built using Docker which includes a multistage build example. The whole application is served with Docker Compose.

Running the code

To run the example, clone the Github repository and start the services with Docker Compose. Once Docker finishes downloading and building images, the front end is accessible by visiting localhost:8080 in a browser.

git clone https://github.com/ebosas/microservices
cd microservices
docker-compose up

Back end

To access the back end service, attach to its docker container from a separate terminal window. Messages from the front end will show up here. Also, standart input from this service is sent to the front end to have communication both ways.

docker attach microservices_backend

Database

To inspect the database, launch a new container that will connect to our Postgres database. Then enter the password demopsw (see the .env file).

docker run -it --rm --network microservices_network postgres:13-alpine psql -h postgres -U postgres

Select everything from the messages table:

\c microservices
select * from messages;
Languages
Go 58.6%
TypeScript 19.9%
HTML 10.1%
Dockerfile 6%
SCSS 5.4%