Buy-Better Product Server
Table of contents
Overview
Buy Better Product server is a grpc server that responsible for the products related logic.
example GetProductsByUser etc.
NOTE: This project is for learning purpose and not fully complete yet
Project structure
├── .gen # auto generated by jet-db
│ ├── buy-better-core
├── .github
│ ├── workflows
├── bin # go binary
├── deploy # helm chart
│ ├── bb-product-server # project helm chart
├── cmd
│ └── server # main package for product service
├── internal
│ ├── product # product service handler
│ └── store # database logic
└── k8s
├── base # kustomize base
└── dev # patch kustomize
Dependencies
Infrastructure
- docker / docker-compose
- minikube
- kubectl / kustomize
- helm
Developer Setup
- Create environment variable store in
.env file at root directory
DB_DRIVER="postgres"
DB_DSN="postgresql://postgres:admin1234@localhost:5433/buy-better-core?sslmode=disable"
DB_MAX_OPEN_CONNS=25
DB_MAX_IDLE_CONNS=25
DB_MAX_IDLE_TIME="15m"
environment variables must be match with Makefile
- Visit
Makefile There are 2 important variables for local development. Feel free to edit.
DB_DSN
DB_NAME
DB_USERNAME
CONTAINER_NAME
-
Please visit Buy-Better-Core and run make dev-db-up from there
-
go run cmd/server start the service with port :3031
Running Test
go test ./... -v Currently, There is unit test only.
Running in local cluster minikube
Please keep in mind. This project meant to be running with other service.
make dev-apply to apply product service to local cluster
Postman testing
Please import the proto file from Buy-Better-Proto
Useful Command/Makefile
Please visit Makefile for the full command.
make jet-gen generate a type safe from database. run this command everytime there is a change in database schema.
mockery generate a mock file. please visit .mockery.yaml for the setting
make dev stop delete the product service resource
TODO
- Add grpc healthcheck
- Make address as an environment variable