search

command module
v0.0.0-...-e7367dc Latest Latest
Warning

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

Go to latest
Published: Oct 24, 2019 License: MIT Imports: 10 Imported by: 0

README

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

Requirements

go version 1.13
docker
docker-compose
golang-statik: sudo apt install golang-statik
mockgen: sudo apt install mockgen

Installation

Use go mod to install dependencies.

go mod tidy

Run docker-compose to build docker images and run containers.

docker-compose up -d

if the command above returns this error

es01 exited with code 78

that 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=524288

Now 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=524288

to the end of /etc/sysctl.conf

Usage
docker-compose up -d

wait some time until elasticsearch is ready

  • open Search API
  • use Api-Key: e9435160-1df0-4d27-b0bf-9b3edd9d5737 for authentication

Testing

Example tests added in controller/controller_test.go

For production systems make sure the coverage is 100%

go test ./... -race -cover

Create Mock
 mockgen -source=[interface_name].go -destination=[interface_name]_mock.go -package=[package_name]

Swagger update

Architecture and Design

The project code follows the design principles from the resources bellow

Microsoft Micro-Services

https://docs.microsoft.com/en-us/dotnet/architecture/microservices/index

Uber Go Code Structure

https://www.youtube.com/watch?v=nLskCRJOdxM

  • extended with receivers and emitters for working with events
Rest HTTP Server by Go veteran

https://www.youtube.com/watch?v=rWBSMsLG8po

License

MIT

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
app
gen
pkg
es
api

Jump to

Keyboard shortcuts

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