Skip to content

👴 This repo for practicing gRPC server using Golang, PostgreSQL, Docker, Travis CI and CodeCov

License

Notifications You must be signed in to change notification settings

moemoe89/go-grpc-server-tisa

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Build Status codecov Go Report Card

GO-GRPC-SERVER-TISA

Practicing GRPC Server using Golang as Programming Language, PostgreSQL as Database

Directory structure

Your project directory structure should look like this

  + your_gopath/
  |
  +--+ src/github.com/moemoe89
  |  |
  |  +--+ go-grpc-server-tisa/
  |     |
  |     +--+ main.go
  |        + api/
  |        + routers/
  |        + ... any other source code
  |
  +--+ bin/
  |  |
  |  +-- ... executable file
  |
  +--+ pkg/
     |
     +-- ... all dependency_library required

Setup and Build

$ mkdir -p src/github.com/moemoe89
$ cd src/github.com/moemoe89
$ git clone <url>
$ mv <cloned directory> go-grpc-server-tisa

Running Migration

  • Copy config-sample.json to config.json and changes the value based on your configurations.
  • Create PostgreSQL database for example named simple_api and do migration with Goose https://bitbucket.org/liamstask/goose/
  • Change database configuration on dbconf.yml like dialect and dsn for each environtment
  • Do the following command
$ cd $GOPATH/src/github.com/moemoe89/go-grpc-server-tisa
$ goose -env=development up

Running Application with Makefile

Make config file for local :

$ cp config-sample.json config-local.json

Build

$ cd $GOPATH/src/github.com/moemoe89/go-grpc-server-tisa
$ make build

Run

$ cd $GOPATH/src/github.com/moemoe89/go-grpc-server-tisa
$ make run

Stop

$ cd $GOPATH/src/github.com/moemoe89/go-grpc-server-tisa
$ make stop

Make config file for docker :

$ cp config-sample.json config-docker.json

Docker Build

$ cd $GOPATH/src/github.com/moemoe89/go-grpc-server-tisa
$ make docker-build

Docker Up

$ cd $GOPATH/src/github.com/moemoe89/go-grpc-server-tisa
$ make docker-up

Docker Down

$ cd $GOPATH/src/github.com/moemoe89/go-grpc-server-tisa
$ make docker-down

How to Run with Docker

Make config file for docker :

$ cp config-sample.json config.json

Build

$ docker-compose build

Run

$ docker-compose up

Stop

$ docker-compose down

How to Test gRPC

  • Open BloomRPC
  • Import proto file
  • Fill server address & port
  • Do testing

How to Run Unit Test

Run

$ go test ./...

Run with cover

$ go test ./... -cover

Run with HTML output

$ go test ./... -coverprofile=c.out && go tool cover -html=c.out

Reference

Thanks to this medium link for sharing the great article

License

MIT

About

👴 This repo for practicing gRPC server using Golang, PostgreSQL, Docker, Travis CI and CodeCov

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages