Skip to content

Client API

Alex Dean edited this page Feb 23, 2014 · 1 revision

There are only three possible actions a client can take (currently) on the database: Adding a file, removing a block, or getting a block.

Current Implementation:

To Get a Block: {"msg":"get","key":<KEY>}

  • Note that upon successful retrieval, the server will send back: {"msg":"get","key":<KEY>,"val":<VALUE>}
  • And then upon a missing block you should get back: {"msg":"err","val":"missing"}
  • Other errors will have different values for "val".
  • The connection will remain open for further messages.

To Delete a Block: {"msg":"del","key":<KEY>,"oid":<OID>}

  • Note that upon successful removal, the server will stay silent.
  • Upon any error you will get back: {"msg":"err","val":<REASON>}
  • The connection will remain open for further messages.

To Add a Block: {"msg":"add","expires":<EXPIRES>,"removable":<REMOVABLE>}

  • Note after sending this message, the connection switches modes and will only accept block messages of the form: {"key":<KEY>,"val":<VALUE>}
  • As verification that the mode has been switched over, the server will first send the generated ownership id: {"msg":"ack","oid":<OID>}
  • Once all block messages are finished, closing the connection cleanly will tell the server to complete it's buffer of block adds.

Variable Definitions:

  • <KEY> - DISTRESS makes no requirements on what a key can be, but for our client we are using hashes of size 384.
  • <VALUE> - DISTRESS, like keys, makes no requirements on what values can be, but for our client we are using block sizes of 512 bytes.
  • <OID> - This will be a string of a UUID RFC4122 version 4. We have not experimented with alternative ownership ids.
  • <REASON> - This will be a string. It will most commonly be "badarg" if not "missing" which means your message was poorly constructed or missing a value.
  • <EXPIRES> - This will either need to be the string, "infinity" or an integer unix timestamp of a future time/date. This is an optional value, as it defaults to "infinity".
  • <REMOVABLE> - This needs to be a JSON boolean value. This is an optional value, as it defaults to false.

Clone this wiki locally