Giter Club home page Giter Club logo

mq-to-db's Introduction

mq-to-db

This is a Golang (go) program to read from a Message Queue System and Store into Database using concurrency as you can see into the image below

mq-to-db

Consumers supported

Storage supported

Characteristics

  • The number of queue consumers could be different from the numbers of storage workers
  • The process (job) of consume one message from queue and store into the database is synchronous because every message needs to be acknowledge (confirm as storage).
  • Prometheus metrics for consumers, storage workers, go statistics and database.
  • Grafana dashboard for prometheus metrics
  • Dockerfile multi-stage build
  • Makefile to facilitate the project builds
  • docker-compose file and configuration to test all elements

How to execute

source code

git clone https://github.com/christiangda/mq-to-db.git
cd mq-to-db/
go run -race  ./cmd/mq-to-db/main.go --help

# and then
go run -race  ./cmd/mq-to-db/main.go --configFile config-sample.yaml

NOTE: the parameter -raceis to check race conditions because we are using Go Concurrency

binary

./mq-to-db --help

RabbitMQ

docker run -it --rm --name rabbitmq -p 5672:5672 -p 15672:15672 rabbitmq:3-management

NOTE:

PostgreSQL

docker run --rm  --name postgresql -e POSTGRES_PASSWORD=mysecretpassword -p 5432:5432 -d postgres

# logs
docker logs postgresql -f

# remember to  stop and remove (--rm in docker run do it for you)
docker stop postgresql

mq-to-db

go run -race  ./cmd/mq-to-db/main.go --configFile config-sample.yaml

o

make
./mq-to-db --configFile config-sample.yaml

docker-compose

Up

docker-compose up --build

Down

docker-compose down -v

Links

Logs

docker-compose logs mq-to-db-01
docker-compose logs mq-to-db-02

How to build

Manually

go build \
    -o mq-to-db \
    -ldflags "-X github.com/christiangda/mq-to-db/internal/version.Version=$(git rev-parse --abbrev-ref HEAD) -X github.com/christiangda/mq-to-db/internal/version.Revision=$(git rev-parse HEAD) -X github.com/christiangda/mq-to-db/internal/version.Branch=$(git rev-parse --abbrev-ref HEAD) -X github.com/christiangda/mq-to-db/internal/version.BuildUser=\"$(git config --get user.name | tr -d '\040\011\012\015\n')\" -X github.com/christiangda/mq-to-db/internal/version.BuildDate=$(date +'%Y-%m-%dT%H:%M:%S')" \
    ./cmd/mq-to-db/main.go

Automatic

make

NOTES related to make

    1. This create a linux binary (64bits) and also Docker Image (linux 64 bit)
    1. Check the Makefile to see the make targets

Internal References

External References

Free books

Blogs

Databases

Project Layout

Interfaces

Context

YAML|JSON to Struts

Config Files, Flags, Env Vars

RabbitMQ

Logs

### Metrics

### Tests

Variable Injection

Iterators

Concurrency

Workers Pool

mq-to-db's People

Contributors

christiangda 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.