A Go-based microservice for tracking and reporting popular multiplayer game modes.
This project implements a multiplayer modes service that allows tracking and reporting popular game modes. It uses gRPC for communication and MongoDB for data storage. The service provides two main functionalities:
- Reporting mode playing: Increment player counts for specific game modes.
- Getting popular modes: Retrieve a list of popular game modes sorted by player count.
- Real-time updating of mode popularity
- Efficient caching mechanism for frequently accessed data
- Scalable architecture using gRPC and MongoDB
- Docker support for easy deployment
To install the necessary dependencies: bash make build
This command will build the binary for the service.
To start the service locally:
bash make run
To build and run the service using Docker:
bash docker-compose up --build
This will start both the service and a MongoDB instance.
The service exposes two main endpoints:
ReportModePlaying: Increments the player count for a specific mode.GetPopularModes: Retrieves a list of popular modes sorted by player count.
See the API Documentation section for more details.
The service uses gRPC protocol. You can find the protobuf definitions in the proto/service.proto file.
To generate client code for your preferred language, use the following command:
bash protoc --go_out=. --go_opt=paths=source_relative --go-grpc_out=. --go-grpc_opt=paths=source_relative proto/service.proto
To start developing:
-
Clone the repository: bash git clone https://github.com/your-repo/multiplayer-modes-service.git cd multiplayer-modes-service
-
Set up your development environment:
- Install Go (version 1.23 or later)
- Install Docker and Docker Compose
-
Run tests: bash make test
-
Start the service locally: bash make run
The project includes unit tests for both business logic and storage layers. To run all tests:
bash make test
The service can be deployed using Docker. Here's a basic deployment process:
-
Build the Docker image: bash docker build -t multiplayer-modes-app .
-
Run the container: bash docker run -p 8080:8080 --env-file .env multiplayer-modes-app