Tutorial

Create a docker network to use

docker network create nibble

Start one backend

docker run -it --name foo --network="nibble" jptmoore/nibbledb

Start another backend

docker run -it --name bar --network="nibble" jptmoore/nibbledb

Start the gateway

docker run -p 5000:5000 -it --network="nibble" jptmoore/nibblegw --hosts "http://foo:8000, http://bar:8000"

Post some data

curl --request POST --data '[{"value": 1}, {"value": 2}, {"value": 3}, {"value": 4}, {"value": 5}]' http://localhost:5000/ts/foo
curl --request POST --data '[{"value": 6}, {"value": 7}, {"value": 8}, {"value": 9}, {"value": 10}]' http://localhost:5000/ts/foo
curl --request POST --data '[{"value": 11}, {"value": 12}, {"value": 13}, {"value": 14}, {"value": 15}]' http://localhost:5000/ts/foo
The data is distributed across the two backends.

Run a query

curl http://localhost:5000/ts/foo/length
{"length":15}

Add more backend hosts

curl -X POST http://localhost:5000/ctl/host/add -d '[{"host":"http://foo:8000"}]'
Error:host already exists
docker run -it --name baz --network="nibble" jptmoore/nibbledb
curl -X POST http://localhost:5000/ctl/host/add -d '[{"host":"http://baz:8000"}]'

Removing backend hosts

curl -X POST http://localhost:5000/ctl/host/remove -d '[{"host":"http://baz:8000"}]'
The data from the removed backend host will be distributed across the remaining backends.

List the backend hosts

curl http://localhost:5000/info/host/list
{"hosts":["http://foo:8000","http://bar:8000"]}

Get the number of backend hosts

curl http://localhost:5000/info/host/count
{"count":2}

Get names of time series

curl http://localhost:5000/info/ts/names
{"timeseries":["foo"]}
Which means across our backend servers named foo and bar we have created one time series called foo.

Get stats on the backend servers

curl http://localhost:5000/info/ts/stats
[
{
"http://foo:8000/info/ts/stats": [
{
"length": [
{
"foo": 10
}
]
},
{
"length_in_memory": [
{
"foo": 10
}
]
},
{
"length_on_disk": [
{
"foo": 0
}
]
},
{
"length_of_index": [
{
"foo": 0
}
]
}
]
},
{
"http://bar:8000/info/ts/stats": [
{
"length": [
{
"foo": 5
}
]
},
{
"length_in_memory": [
{
"foo": 5
}
]
},
{
"length_on_disk": [
{
"foo": 0
}
]
},
{
"length_of_index": [
{
"foo": 0
}
]
}
]
}
]