Skip to content

slowhigh/gogger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

64 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gogger (go + logger)

Distributed Logging

- producer server 📋

Build Status Go Report Card codebeat badge

- consumer server 📋

Build Status Go Report Card codebeat badge

Quick start 🚀

1. Deploy Memphis Broker

$ curl -s https://memphisdev.github.io/memphis-docker/docker-compose.yml -o docker-compose.yml \
&& docker compose -f docker-compose.yml -p memphis up -d

2. Deploy Postgres

$ docker run -d \
-p 5432:5432 \
-e POSTGRES_USER=gogger \
-e POSTGRES_PASSWORD=gogger1! \
-e POSTGRES_DB=gogger \
--name postgres postgres:alpine

3. Run Consumer Server

$ cd ./consumer/ && go run ./cmd/server/

# 2024/01/28 23:13:12 INFO start consuming messages

4. Run Producer Server (new terminal)

$ cd ./producer/ && go run ./cmd/server/

# [GIN-debug] [WARNING] Creating an Engine instance with the Logger and Recovery middleware already attached.
# 
# [GIN-debug] [WARNING] Running in "debug" mode. Switch to "release" mode in production.
#  - using env:   export GIN_MODE=release
#  - using code:  gin.SetMode(gin.ReleaseMode)
# 
# [GIN-debug] POST   /log/access               --> github.com/Slowhigh/gogger/producer/infra/router.NewRouter.func1 (3 handlers)
# [GIN-debug] [WARNING] You trusted all proxies, this is NOT safe. We recommend you to set a value.
# Please check https://pkg.go.dev/github.com/gin-gonic/gin#readme-don-t-trust-all-proxies for details. 
# [GIN-debug] Listening and serving HTTP on :5000

5. Send the HTTP message to the Producer (new terminal)

$ curl --location 'http://localhost:5000/log/access' \
--header 'Content-Type: application/json' \
--data '{
    "timestamp": "2006-01-02T15:04:05Z",
    "is_normal_mode": true,
    "is_login": true,
    "user_name": "john",
    "device_name": "slowhigh",
    "ip": "192.168.0.1"
}'

6. Check the message on the Station page