Skip to content

This is an example of implementation of RabbitMQ in golang

Notifications You must be signed in to change notification settings

arvians-id/go-rabbitmq

Repository files navigation

Example of RabbitMQ in Golang

This is an example of implementation of RabbitMQ in Golang.

Requirements

Make sure you have installed all of the following prerequisites on your development machine:

Installation

This project requires Go v1.20+ to run.

# Clone this project
$ git clone https://github.com/arvians-id/go-rabbitmq.git

# Move to project directory
$ cd go-rabbitmq

# Copy .env.example to .env
$ cp services/category/.env.example services/category/.env \
    && cp services/todo/.env.example services/todo/.env \
    && cp services/user/.env.example services/user/.env \
    && cp services/worker/.env.example services/worker/.env \
    && cp services/category_todo/.env.example services/category_todo/.env \
    && cp gateway/.env.example gateway/.env

# Move to each directory and install the dependencies
$ go mod download
# or
$ go mod tidy

# Migrate tables
$ make migrate table=go_rabbitmq verbose=up
$ make migrate table=go_rabbitmq_test verbose=up

# After installing protocol buffers, generate the proto file
$ make pb

Run Application

On Development

# Run all containers
$ docker-compose -f docker-compose.dev.yml up -d

# Run all services
# Warning: Make sure you have running all services in different terminal
$ go run cmd/category/main.go
$ go run cmd/todo/main.go
$ go run cmd/user/main.go
$ go run cmd/worker/main.go
$ go run cmd/category_todo/main.go
$ go run cmd/gateway/main.go

# or you can run all services in different terminal with air
$ air

# graphql playground, open in browser
http://localhost:3000/playground

# rest api, open in postman or curl
$ curl -X GET http://localhost:3000/api/users

# Run test
# Warning: Make sure you have run on development mode
$ make test

On Production

# Build all services
$ make build

# Run database on docker
$ docker-compose up -d

Technologies Used

About

This is an example of implementation of RabbitMQ in golang

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages