SettingsService

module
v0.0.0-...-96f9455 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 28, 2024 License: MIT

README

About

Self-learning Golang project.
Store and managing settings for microservices.

Used packages

backend:

Golang

frontend

Vue

Develop

Recommended IDE - VSCode.
Environment for project in ./.vscode/launch.json.
For another IDE's don't forget set up env variables:

"SettingsServicePort": "9000",
"SettingsServiceDbConnectionString": "postgres://pg:1@localhost:5432/servicesSettings_db",
"SettingsServiceEnv": "dev"

Requiremens

  1. Go
  2. Node
  1. Docker
  2. Go
  3. npm Intellisense
  4. REST Client
  5. TypeScript Vue Plugin (Volar)
  6. Volar

! disable Vetur

Debug & Test

Debug backend

  1. Install golang swag utility:

    go install github.com/swaggo/swag/cmd/swag@latest
    
  2. Install dependencies:

    go get .
    
  3. Run test database docker image:

    docker compose up -d ./.test/database/docker-compose.yml
    
  4. After changes regenerate swagger files:

    swag init -g ./cmd/SettingsService/main.go -o ./docs
    
  5. Set breakpoints and press F5

Debug frontend

  1. Install node

  2. Move to ./web/src

  3. Install dependencies npm install

  4. npm run dev

Run in Docker

make front
docker build --tag 'settingsservice' .
docker run -d -p 9000:9000 --name 'SettingsService' 'settingsservice'

or prepare image with tag settingsservice

make image

or run container with tag settingsservice and name SettingsService

make docker

Production

build with remove the symbol and debug info:

go build -o=SettingsService -ldflags "-s -w" ./cmd/SettingsService
(cd ./web/src/ && npm install && npm run build)

where:

  • -w turns off DWARF debugging information
  • -s turns off generation of the Go symbol table

or use Makefile:

make help

For non-docker environment don't forget set up env variables:

"SettingsServicePort": "9000",
"SettingsServiceDbConnectionString": "postgres://pg:1@localhost:5432/servicesSettings_db"

TO DO

  1. healthchecks
  2. Add push mechanism for setting's updates
  3. Add auth
  4. Add unit-tests
  5. Try another DB, for example mongo
  6. fix config. How do it best? Now ENV
  7. Write help instructions

History

  1. Appy project layout
  2. makefile
  3. versioning
  4. SPA
  5. fix results of stat analyst (except swagger comments)
  6. dockerize

Directories

Path Synopsis
cmd
SettingsService command
Package docs Code generated by swaggo/swag.
Package docs Code generated by swaggo/swag.
internal
dal
dto

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL