Skip to content

Real-Dev-Squad/discord-message-broker

Repository files navigation

Discord Message Broker Setup and Running Instructions

This document provides instructions on how to set up and run the Go project using the provided Makefile commands.

Requirements

  • Go 1.18+
  • Make
  • Air (for make air)

Ensure you have these dependencies installed before running the commands.

Prerequisites

Before running the project, ensure that you have the following installed:

  • Go 1.18+: The Go programming language (required to run and build the project).
  • Air: A live-reloading tool for Go that will automatically restart the project on file changes.
  • Make: A build automation tool used to manage tasks defined in the Makefile.

Installation

  1. Install Go If you don't have Go installed, follow the official guide to install it:Go Installation Guide.
  2. Install Make To install Make, follow the installations steps from here based on your OS: Make Installation Guide.
  3. Install Air To install Air, follow the installation steps here: Air Installation Guide

Running Discord Message Broker

There are 2 ways of running Queue and Consumer,

  • either you can setup both with docker if you are not working on consumer
  • but in case if you are working on consumer and want hot reloading, go with running consumer manually

Way 1: Running both RabbitMQ & Consumer using Docker

Set the following env var(s)

QUEUE_URL = "amqp://rabbitmq:5672"
DISCORD_SERVICE_URL = "http://host.docker.internal:<PORT>"
DISCORD_QUEUE = <ANY_NAME> #Default: "DISCORD_QUEUE"

Run the compose command:

docker-compose up --build

Way 2: Running RabbitMQ with Docker & Consumer manually

Running only RabbitMQ with Docker

docker compose -f 'docker-compose.yml' up -d --build 'rabbitmq'

Important

To check if the queue is running or not, visit http://localhost:15672

RabbitMQ UI

This is how the UI will look like once you open http://localhost:15672

Image

Important

User "guest" as username and password

Running Consumer Manually

Set the following env var(s)

QUEUE_URL = "amqp://localhost:5672"
DISCORD_QUEUE = <ANY_NAME> #Default: "DISCORD_QUEUE"
DISCORD_SERVICE_URL = "http://localhost:<PORT>"

Manual Setup

  1. Install Packages
   go mod download
  1. Verify Packages If it's your first time running the project, ensure all dependencies are set up:

    go mod tidy
  2. Running the Project

    go run .
  3. Running the Project Using Air

    air

Running the Project Using Make

You can run the project using the Makefile, which provides several commands for various tasks. Below are the steps to run the project:

  1. Install Packages

    make download
  2. Verify Packages If it's your first time running the project, ensure all dependencies are set up:

    make tidy
  3. Running the Project

    make run
  4. Running the Project Using Air

    make air

Other Commands In Usage

  1. To run tests:

    make test #or go list ./... | grep -v "/config$$" | grep -v "/routes$$" | xargs go test -v
  2. To generate a coverage report:

    make coverage #or go list ./... | grep -v "/config$$" | grep -v "/routes$$" | xargs go test -v -coverprofile=coverage.out
  3. To automatically re-run the application on changes:

    make air #or air
  4. To clean up the generated files:

    make clean #or rm -rf coverage coverage.out coverage.html

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •