graph-service
The Graph Service (Repository?) handles transactions and queries to the graph database.
Getting Started
To clone the repo:
git clone git@gitlab.com/dctx/devcon-contact-tracer.git
cd graph-service
A docker image is also avaible in Docker Hub:
docker pull dctx/graph-service:latest
Prerequisire
Workspace
Docker images
- Kafka (bitnami/kafka:2.4.1)
- Neo4J (neo4j:4.0.1)
Deployment
- Docker Compose
- Kubernetes (minikube)
- Helm
Build
Run the following to build the binary:
make build
The binary will be located in: build/bin/graph-service
Configuration
Configuration is handled by viper which allows configuration using a config file or by environment variables.
A sample configuration file can be found in config/.graph-service.yaml
. Copy this to the $HOME
directory to override the defaults.
Setting environment variables can also override the default configuration:
Migrations
Execute the following to run the database migrations:
make migrate
Starting the Service
make run
Packaging Image
To create the docker image:
make package
To publish the image to docker hub:
make publish
Note that publishing the image requires access to the dctx group in docker hub.
Development
This project follows gitlab flow. The general flow is:
- Pick / Create an issue
- Create a feature branch
- Open a Merge Request
- Maintainer merge's to
master
Read more about gitlab flow here.
Project Structure
graph-service
|- build/ # build artifacts are generated here
|- cmd/ # command line commands live here. Checkout cobra library
|- config/ # configuration files are here
|- db/ # for database migration files
|- helm/ # helm chart for kubernetes deployment
|- internal/ # for internal go packages
| |- migration
| |- server
| |- ...
|- pkg/ # for public go packages
|- .dockerignore # ignore list for docker
|- .gitignore # ignore list for git
|- go.mod # dependencies for project
|- go.sum # checksum for dependencies, do not manually change
|- main.go # the main go file
|- Makefile # build scripts
|- README.md # this file
Adding Dependencies
To add dependencies, run the following:
go get -u {dependency}
make deps
TODO
Initial ToDo list:
TROUBLESHOOTING
Detailing here some of the issues in the development of the service
Seabolt
The Neo4j Golang Driver uses seabolt
It has to be installed separately
https://github.com/neo4j-drivers/seabolt
Installation of seabolt differs for each platform (e.g Ubuntu, MacOS)
Wire
Wire is dependency injection tool for Go
To add a singleton, define "providers" in wire.go, then run this the command
go generate ./cmd
This should update the autogenerated file wire-gen.go
Viper
Viper is for Go configuration
The config file (e.g .graph-service.yaml) should be in the directory ~/
Common issues