Git Product home page Git Product logo

go-12factor-scaffold's Introduction

Go Rest micro-service


Go Report Card

Using 12Factor Methodology

Instructions and Usage

Action Command
Build make build
Migrate make migrate
Deploy make run

Benchmard (write only)

PASS
ok   github.com/by-sabbir/go-12factor-scaffold/transport/http 8.490s

by-sabbir/go-12factor-scaffold benchmark

Help Text

Available Commands:
  completion  Generate the autocompletion script for the specified shell
  help        Help about any command
  migrate     Migrate Database
  server      runs the server

Flags:
      --config string   config file (default is ./config.yaml)
  -h, --help            help for 12Factor-App
  -t, --toggle          Help message for toggle

I. Codebase     Deployment is maintained from branches ie. master -> production, dev -> test, staging -> uat.

II. Dependencies     In our case, go.mod files will seperate all the dependencies specifically for your project.

III. Config     In this project we can pass configurations as parameter, go run main.go server --config <yaml path>.

IV. Backing services     We used postgres and rabbitmq as the backing services and they can be attached from the config as we need.

V. Build, release, run Strictly separate build and run stages, means we have to maintain a CICD to seperate build, test, and deploy environments. For this example, I have seperated the stages with Makefile

VI. Processes This means we have to maintain our backend as a stateless independent process so that we can scale better. We are managing the application state in rabbitmq and it's fully independent.

VII. Port binding Export services via port binding, in our case 9091

VIII. Concurrency Concurrency is built into go.

IX. Disposability I have used SIGTERM and SIGKILL for graceful shutdown. So that, the app waits for a specific amount of time to process existing concurrent request before it forcefully shuts down.

X. Dev/prod parity Again this depends on how we setup/plan our CICD. For our application we have config.yaml and dev.yaml for simulating this case. Also for gin specific application, we can sperate debug/production with a environment variable - GIN_MODE=release

XI. Logs I have used logrus for structure logging.

XII. Admin processes cobra is used to create admin processes. Following admin processes are available in our app:

  migrate     Migrate Database with golang-migrate
    up        Apply Migration
    down      Undo Migration (not implemented)
  server      runs the server

go-12factor-scaffold's People

Contributors

by-sabbir avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.