šŸš€ Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more →
Socket
Sign inDemoInstall
Socket

gitlab.com/dctx/devcon-contact-tracer/graph-service

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gitlab.com/dctx/devcon-contact-tracer/graph-service

v0.0.0-20200323011501-64d20e4f8cab
Source
Go
Version published
Created
Source

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

  • Go
  • Docker

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:

Environment VariableDescriptionDefault

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:

  • Improve this README
  • Setup Gitlab CI/CD
  • Create the db migrations
  • Create kafka connector
  • Define features in Gitlab Issues or Trello

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

  • wire isn't a known command The wire dependency should be in the vendor folder after cloning, the problem could be PATH
    export PATH=$PATH:$GOPATH/bin
    

FAQs

Package last updated on 23 Mar 2020

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts