Skip to content

Str1kez/SportiqSubscriptionService

Repository files navigation

Subscription Microservice for Sportiq project

This microservice is responsible for consuming messages from queue and processing subscription operations. Microservice is splitted into two part: HTTP-server and message consumer.

Microservice Architecture Microservice Architecture

Related Sportiq services

Documentation

OpenAPI - https://str1kez.github.io/SportiqSubscriptionService

Message handler

Message handler is based on Rabbit MQ, has N parallel workers on goroutines. Variable can be set in .env.
History is stored in PostgreSQL, subscription data is stored in ReJSON module with RediSearch support. This allows to improve the speed of working on frequently changing data.

Preparing to start

You can execute only one command to startup the microservice:

docker compose up -d --remove-orphans --build

Or do it manually:

  1. Create .env file and fill it:
    make env
    
  2. Make migrations
  3. Build Docker-image:
    make build-image-handler
    
  4. Check Start on HTTP-server

HTTP-server

The server allows the user to interact with the microservice. It runs on gin framework with parallel workers.

Start

You can execute only one command to startup the microservice:

docker compose up -d --remove-orphans --build

Or do it manually:

  1. Create .env file and fill it (if didn't do it on message handler step):
    make env
    
  2. Make migrations (if didn't do it on message handler step)
  3. Build Docker-image:
    make build-image-server
    
  4. Start the microservice:
    make up
    

Migrations

Need to install migrate

go install -tags 'postgres' github.com/golang-migrate/migrate/v4/cmd/migrate@latest

After that you must run migrations with fullfilled .env.dev file

TODO

  • Create a reserve queue for unprocessed messages
  • Improve code architecture (more separated layers)