Micro-service with functionality for adding, deleting and searching for products in a product catalog elastic DB.
Supports full-text search, with filters, sorting and pagination.
It has simple api-key authentication and versioning.
Open API 3.0 UI
DB and App dockerized
Simple CI for GitHub and GitLab
go version 1.13
docker
docker-compose
golang-statik: sudo apt install golang-statik
mockgen: sudo apt install mockgenUse go mod to install dependencies.
go mod tidyRun docker-compose to build docker images and run containers.
docker-compose up -dif the command above returns this error
es01 exited with code 78that is because
elasticsearch | [1]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]Therefore we need to increase the vm.max_map_count limit:
sudo sysctl -w vm.max_map_count=524288Now we need to edit /etc/sysctl.conf so the setting will also be in effect after a reboot.
Look for any vm.max_map_count line in /etc/sysctl.conf. If you find one, set its value to 524288. If there is no such line present, add the line
vm.max_map_count=524288to the end of /etc/sysctl.conf
docker-compose up -dwait some time until elasticsearch is ready
- open Search API
- use Api-Key: e9435160-1df0-4d27-b0bf-9b3edd9d5737 for authentication
Example tests added in controller/controller_test.go
For production systems make sure the coverage is 100%
go test ./... -race -cover
mockgen -source=[interface_name].go -destination=[interface_name]_mock.go -package=[package_name]- use http://editor.swagger.io
- modify app/swagger/swagger.yaml
- run: statik -src=./app/swagger -dest=./app
The project code follows the design principles from the resources bellow
https://docs.microsoft.com/en-us/dotnet/architecture/microservices/index
https://www.youtube.com/watch?v=nLskCRJOdxM
- extended with receivers and emitters for working with events