While developing this testing assignment I tried to keep everything as simple and light as possible. Result was tested with Python 2.7 only.
###Back-end
Following technologies are used:
- Tornado is used to implement a websockets server. It's asynchronious and supports an event-loop inside.
- Redis is used as a publish-subscribe bus. To make it compatible with Tornado coroutines gredis is used as Python driver (which is a small async extension of standart redis package).
###API
API for usage from Python code consist of one function: notify. Usage:
from nserv import notify
# level can be {success|info|warning|danger}
notify('A message', 'warning')
###Command-line tool
(env)utyf@utyf-ThinkPad-T420:~/work/viasto$ ./nserv_notify.py --help
usage: nserv_notify.py [-h] -m MESSAGE -l LEVEL
Post a notification.
optional arguments:
-h, --help show this help message and exit
-m MESSAGE, --message MESSAGE
-l LEVEL, --level LEVEL
###Front-end
As front-end is not part of evaluation, I made a small experiment there, writing it in some kind of "functional" style. State is strictly separated from logic, every state transition is a pure function.
Following technologies are used:
- React.js as library for visual components
- Bootstrap as CSS framework
###Install and start
git clone https://github.com/utyf/nserv
cd nserv
# assuming, that python 2.7 is there
virtualenv env
. env/bin/activate
pip install -r requirements.txt
python nserv.py
# in other console (add host and port if needed):
redis-server
# open http://localhost:8080/