Skip to content

Latest commit

 

History

History
108 lines (79 loc) · 2.64 KB

Readme.md

File metadata and controls

108 lines (79 loc) · 2.64 KB

The The Board Game

The Board Game is a practice task that include work with Message Queue, DB, APi and Worker

We have online game platform. There are many games and a lot of players. Every player have number of points that he collected started from first game. Number of points could be changed up to several times per game Also we have the scores where displayed in special window.

Environment

You could use any DB or Queue what do you want.

To make working easier we've created a docker-compose file with RabbitMQ and PostgreSQL inside.

To run use command:

docker-compose up -d

RabbitMQ credentials:

PASSWORD=my_password
USER=my_user

PostgreSQL credentials

PASSWORD=my_password
USER=my_user

API

You need to implement two endpoints, that described in the swagger.yml file inside of api folder

Server code MUST be generated by Go-Swagger tool, to do it please follow the next steps:

cd api

swagger generate server 
go get -u -f ./...    

To run server do following:

./api/cmd/board-game-server/main.go

Please create and configure handlers to respond on HTTP requests. You could do it in:

api/restapi/configure_board_game.go

This file is generated by Go-Swagger, but it is permanent and will not regenerated. So you could edit this file for your needs

Users

There is no Not Found errors processing, because we expected that you will work only with existing users. So, you have to add test users to your database, before you will work with endpoints.

Worker

You need to implement worker that wake up every 10 minutes, get all messages from queue, group them by UserID and update records in the database.

Write logs when worker wake up and finish his task.

Implement:

cmd/score_collector_worker/main.go
app/services/score_collector.go
app/repositories/scores.go

Please, do not change signature of public methods for the structures.

Structure dependencies

Please use DI to pass dependencies in the structure.

app/services/scores_collector.go

Init all your dependencies inside of:

app/dependencies.go

Tests

All code MUST be covered by unit tests. See simple unit test with mocks example at:

app/services/scores_collector_test.go

Do not forget to cover your api handlers by tests.

Linter

On this project we have configured golangci linter. Install linter due to this manual on your local machine. Do not forget to check your code with golangci.

golangci-lint run