LikeAFalcon
is an event driven system, receives an event and then sent it to a NATS Stream.
After that watchers will receive notifications depending from the queue in which the event has been written, in this case like.a.falcon
.
The watcher will then save the event inside a db.
You can access a real-time stream using websockets (/ws
) or query the db for the events stored (/query
).
This project uses rampante, a small collection of helpers to work with streams and aiohttp.
Main parts of this app are:
-
app/api.py
Create new events and query the db
-
app/views.py
Websocket offered through a webpage and websocket endpoint
-
app/watchers.py
Watch for new events
Python 3.6.3
Tests are written using PyTest, there is also a linting part before running the tests using flake8
and isort
.
make run-services
pip install tox
tox
make stop-services
docker-compose up -d
The service is then reachable at http://localhost:8080
.
Remeber to run create_db.py
just after you created the db.
Env vars (user, password, db name) has to be set inside config.py
.
python create_db.py
docker-compose stop
docker-compose rm
Accept post request with a json body. The content will be fired to the event stream and then saved inside the database.
Return json body with a list of events stored inside the database. You can specify an offset and limit, by default they are 0 and 10.
Connect to the websocket and receive real-time events sent to /v1/json
.
An html web page that offers a connection to the /ws
endpoint (websocket).
You will see in real-time the event sent to /v1/json
.
- Improve coverage to ~100% (basically add test for the websockets)