An in-memory distributed key-value store implemented in Elixir prioritizing availability and partition-tolerance over consistency Not meant to be a serious implementation of a full-fledged database, but instead a learning experience to get practice with Agents, Tasks, Genservers, Supervisors, and Nodes in Elixir
Note: NectarDB only works on OSX (Macs)
- Execute
brew install erlang
to install the erlang dependencies - Execute
brew install openssl
to install OpenSSL - Clone the repository by executing
git clone https://github.com/KontosTwo/NectarDB.git
- Navigate to NectarDB/bin
- Execute
chmod +x nectar_node.sh
andchmod +x nectar_api.sh
- Open a terminal session and navigate to NectarDB/bin
- Execute
./nectar_api.sh <PORT NUMBER>
and wait for a message in the format of"NectarAPI started at node <name of the api node>"
- You may have to allow beam.smp and other apps to allow connections
- Open a terminal session and navigate to NectarDB/bin
- Execute
./nectar_node.sh <unique name> <name of the api node>
and wait for a message in the format of "NectarNode started at node " - You may have to allow beam.smp and other apps to allow connections
- Write data with the following POST request to
localhost:<PORT NUMBER>/write
, Content-Type set to application/json. You may have as many writes and deletes as you want.
{
"writes" : [
{
"type": "write",
"key": 1,
"value": 2
},
{
"type": "delete",
"key": 1
},
]
}
If the write is successful you will get a message
{
"message": "Successful write!"
}
- Read data with the following POST request to
localhost:<PORT NUMBER>/read
, Content-Type set to application/json. You may have as many reads as you want
{
"reads" : [
{
"type": "read",
"key": 1
},
{
"type": "read",
"key": 2
}
]
}
Depending on if an individual read succeeds, it will appear in either the "successes" or "failures" category
{
"successes": [
{
"key": 1,
"result": 2
}
],
"failures": [
{
"key": 2,
"result": "nodes_unresponsive"
}
]
}
Kill, restart, and add nodes as you please.
- Nodes can be added even after data has begun flowing in
- API nodes can be restarted after crashing
If there are any problems running NectarDB, please shoot me an email