A Microservice example written in Python with an eye-candy browser interface.
- Create and activate a Virtualenv
- pip install -r requirements.txt
- ./app.py
Server Heartbeat:
curl "http://127.0.0.1:8000/"
Insert record:
curl -H "Content-Type: application/json" -X POST -d '{"action": 2, "timestamp": "2017-05-28T16:01:00.00219Z"}' http://127.0.0.1:8000/user/1/
Query:
curl "http://127.0.0.1:8000/user/1/?start=2017-05-28T12:01:00.00213Z&end=2017-05-28T17:03:00.00220Z"
This project uses Apache Cassandra to keep a record of all transactions. This database is only used to persist data.
Cassandra download instructions: http://cassandra.apache.org/download/
- Create Keyspace
CREATE KEYSPACE micropy
WITH REPLICATION = { 'class' : 'SimpleStrategy', 'replication_factor' : 1 }
AND DURABLE_WRITES = True;
- Use Keyspace
USE micropy;
- Create Table
CREATE TABLE actions (
uid int,
action int,
timestamp varchar,
PRIMARY KEY (uid, timestamp, action)
);
- Query
SELECT * FROM actions;
- Unit testing (requests + unittest)
- Continuous Integration