This application depends on the following packages:
- CMake
- AMQP-CPP
- mongo-c-driver
- mongo-cxx-driver
- libconfig++
- Node.js (for web-app only)
- NPM (for web-app only)
- Google Test (for tests only)
- Fantasyname (no need to install, it is embedded)
mkdir build
cd build
cmake ..
make or make <target>
./leaderboard_app.out app.cfg
or
./traffic_generator.out tg.cfg
For more information about Application, please, see Application information
cd web
npm install
npm start
For more information about Web-Application, please, see Web-Application information
mkdir build
cd build
cmake ..
make or make <target>
./leaderboard_test.out
or
./leaderboard_test.out.coverage
make coverage
<browser you like> coverage/index.html
make clean-coverage
Application is a service that handles the following messages:
- id - unique user identifier
- name - user name
Registers the user in an internal storage (database), otherwise return an error
Example: user_registered(666,Devil)
- id - unique user identifier
- name - user name
Rename the user in an internal storage (database), otherwise return an error
Example: user_renamed(666,Angel)
- id - unique user identifier
- time - time with the following format: "%Y-%m-%dT%H:%M:%S"
- amount - amount of money earned from the deal
Store the information about the user deal in an internal storage (database), otherwise return an error
Example: user_deal(666,2006-06-06T06:06:06,9)
- Same as user_deal
- id - unique user identifier
Connect the user to the service. If user is connected, then the service will send leaderboards (Top-10 and +/- 10 users for the curren one) every application.loop-interval (configurable parameter) seconds
Example: user_connected(666)
- id - unique user identifier
Disconnect the user from the service.
Example: user_disconnected(666)
{
"id" : <user id>,
"name" : "<user name>",
"leaderboard" :
{
"time" : "<time in the format %Y-%m-%dT%H:%M:%S>",
"scores" :
[
"position" : <user position>,
"id" : <user id>,
"name" : "<user name>",
"score" : <user score>,
]
}
}
For all users connected and top-10 (id: -1) the service will send such messages to RabbitMQ server.
It implements basic facilities for logging to console and file
The Application sigleton is responsible for the service lifecycle, initialization, configuration, start, stop, deinitialization
This part of application is needed to handle socket events and pass sockets and events to the RabbitMQ library.
Basic handler that wraps AMQP-CPP channel methods
They are needed for messages consuming and publishing respectively
The application implements facilities to store/retreive/update users, connected users and user scores
It is an embedded database. All data will be lost after service restart
This is a RabbitMQ Consumer. All received messages are pushed to the queue.
The processor pops the message from the queue and process it. Also, it sends an ack or nack back to the RabbitMQ server.
One can configure the number of processors
Every X seconds logic loop reads the information about connected users from the database, retreive the information about leaderboard (top-X and for each connected user) and publishes these messages to the RabbitMQ.
- It seems that AMQP-CPP library is not stable in some cases (often, on starting and committing transactions), so, I have an action point to rewrite this part using rabbitmq C API link
- I think that it is better to split this application into two: one will handle all requests and the other will read data from Database and send leaderboards information
- Rework processing queues. We can define own queue for each processor
- Measure performance after bug with AMQP-CPP will be fixed