You've already forked microservices
mirror of
https://github.com/ebosas/microservices.git
synced 2025-07-12 22:41:13 +02:00
Update readme, .env
This commit is contained in:
4
.env
4
.env
@ -2,10 +2,10 @@
|
|||||||
# Add this file to .gitignore when using secret data
|
# Add this file to .gitignore when using secret data
|
||||||
|
|
||||||
# Docker Compose environment
|
# Docker Compose environment
|
||||||
POSTGRES_PASSWORD = postgres
|
POSTGRES_PASSWORD = demopsw
|
||||||
|
|
||||||
# Connection strings
|
# Connection strings
|
||||||
POSTGRES_URL = postgres://postgres:postgres@postgres:5432/microservices
|
POSTGRES_URL = postgres://postgres:demopsw@postgres:5432/microservices
|
||||||
RABBIT_URL = amqp://guest:guest@rabbitmq:5672
|
RABBIT_URL = amqp://guest:guest@rabbitmq:5672
|
||||||
SERVER_ADDR = 0.0.0.0:8080
|
SERVER_ADDR = 0.0.0.0:8080
|
||||||
|
|
||||||
|
17
README.md
17
README.md
@ -1,10 +1,13 @@
|
|||||||
# Microservices
|
# 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.
|
A basic example of microservice architecture which demonstrates communication between a few loosely coupled services.
|
||||||
|
|
||||||
Written in Go, this mainly showcases the exchange of information using RabbitMQ—between back end services—and WebSocket—between front end and back end.
|
* Written in Go
|
||||||
|
* Uses RabbitMQ to communicate between services
|
||||||
The services are built using Docker which includes a multistage build example. The whole application is served with Docker Compose.
|
* Uses WebSocket to talk to the front end
|
||||||
|
* Stores data in PostgreSQL
|
||||||
|
* Uses React for front end development
|
||||||
|
* Builds and runs the application with Docker
|
||||||
|
|
||||||
## Running the code
|
## Running the code
|
||||||
|
|
||||||
@ -20,7 +23,7 @@ docker-compose up
|
|||||||
|
|
||||||
### Back end
|
### 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.
|
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 for two way communication.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
docker attach microservices_backend
|
docker attach microservices_backend
|
||||||
@ -28,7 +31,7 @@ docker attach microservices_backend
|
|||||||
|
|
||||||
### Database
|
### Database
|
||||||
|
|
||||||
To inspect the database, launch a new container that will connect to our Postgres database. Then enter the password `postgres` (see the `.env` file).
|
To inspect the database, launch a new container that will connect to our Postgres database. Then enter the password `demopsw` (see the `.env` file).
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
docker run -it --rm --network microservices_network postgres:13-alpine psql -h postgres -U postgres
|
docker run -it --rm --network microservices_network postgres:13-alpine psql -h postgres -U postgres
|
||||||
@ -43,4 +46,4 @@ select * from messages;
|
|||||||
|
|
||||||
### RabbitMQ management
|
### RabbitMQ management
|
||||||
|
|
||||||
The RabbitMQ management plugin is accessible by visiting `localhost:15672` with `guest` as both username and password.
|
Access the RabbitMQ management interface by visiting `localhost:15672` with `guest` as both username and password.
|
||||||
|
@ -17,7 +17,7 @@ type Config struct {
|
|||||||
func New() *Config {
|
func New() *Config {
|
||||||
return &Config{
|
return &Config{
|
||||||
ServerAddr: getEnv("SERVER_ADDR", "localhost:8080"),
|
ServerAddr: getEnv("SERVER_ADDR", "localhost:8080"),
|
||||||
PostgresURL: getEnv("POSTGRES_URL", "postgres://postgres:postgres@localhost:5432/microservices"),
|
PostgresURL: getEnv("POSTGRES_URL", "postgres://postgres:demopsw@localhost:5432/microservices"),
|
||||||
RabbitURL: getEnv("RABBIT_URL", "amqp://guest:guest@localhost:5672"),
|
RabbitURL: getEnv("RABBIT_URL", "amqp://guest:guest@localhost:5672"),
|
||||||
Exchange: getEnv("EXCHANGE", "main_exchange"),
|
Exchange: getEnv("EXCHANGE", "main_exchange"),
|
||||||
QueueBack: getEnv("QUEUE_BACK", "backend_queue"),
|
QueueBack: getEnv("QUEUE_BACK", "backend_queue"),
|
||||||
|
Reference in New Issue
Block a user