Content¶
Second response part is the content, and the second one is the content.
Depending on your Elevator configuration, once running it will either listen on a tcp:// or ipc:// socket handled by zeromq network library, waiting for requests to come in.
Elevator uses zeromq XREP and XREQ sockets, so that every commands passed through sockets are signed with a client id hash. X sockets queues messages as they come in order to prevent overload.
Finally, Elevator sockets are set to communicate using multipart messages to be able to keep apart responses headers and content for example.
If you’re trying to implement a client, or just curious about how it really works, you can take a look at both source code and python client
Every messages exchanged between Elevator and clients consist in hash maps serialized using msgpack. Hash maps is a common data structure present in most languages, it was used because of it’s simplicity, and similarity with json format, which many developpers are confortable with nowadays. Msgpack is a very popuplar and performant serialization protocol ported to many languages.
Request messages format goes like this:
example:
{
"meta": {
"compression": true,
}
"uid": "theamazingdatabasewewannaupdatemd5hash",
"cmd": "PUT",
"args": ["key", "value"],
}
Responses comes into two parts (multipart). First response part is the Header, and the second one is the content.
example:
{
"meta": {
"compression": true,
}
"status": -1,
"err_code": 0,
"err_msg": "Key doesn't exist",
}
Second response part is the content, and the second one is the content.
As you might have noticed, both requests and response header have a meta field. Though it’s presence is mandatory in requests you can perfectly leave it as an empty hash map if you don’t need it.
It’s goal is to let the client and server set options when they’re exchanging requests and response. Today, only one option is supported, but their might be more coming as the development stream flows.
Meta options:
When you’re dealing with huge masses of datas (and I mean, really huge), you might notice Elevator slowing down sometimes
That’s because of the Response size which has to be sent over network (when your dealing with Elevator on your local machine : generally ther’s no problem). To fight the transfer time, and reduce the response size, Elevator can compress the responses using lz4.
Server responds to some constants whenever it comes to give it commands. In the following listing, dbuid represents the database unique uid to operate the command over, it can be retrieved from a database name via ‘CONNECT’. And batch_uid represents a valid server-side created batch (using BCREATE) to run commands over.
GET : Retrieves a value from a database
MGET : Transactional bulk Get. Retrieves a list of keys values on a frozen database state.
PUT : Inserts a value into a database
DELETE : Deletes a key from a database
RANGE : Retrieves a range of key/value pairs from a database
SLICE : Extracts a slice (key/value pairs) from a database
DBCONNECT : Retrieves a database uid from it’s name. You can then use that uid to run commands over it.
DBMOUNT : Tells Elevator to mount a database. As a default, Elevator only mounts the ‘default’ database. You can only run commands over mounted database. Mounted database fills the Elevator cache, and increases Ram memory consomation.
DBUMOUNT : Tells Elevator to unmount a database, it is then unaccessible until you re-mount it. As a default, every databases except ‘default’ are unmounted. Once a database is unmounted Elevator tries to free as much cache it used as possible.
DBCREATE : Creates a new database
DBLIST : Lists server’s databases
DBREPAIR : Repairs a broken (or too slow) database you already owns uid
As Elevator uses leveldb as a storage backend, you can operate a rather precise configuration of your databases using leveldb backend. Options covers database high level behavior, filesystem operations, and cache management. You can find more details about configuration in leveldb documentation
Here is a description offered by py-leveldb of the available options.
Options should be passed as a hash map with the DBCREATE function. It comes with default values which will be overrided with the ones you set.
execute server-side. Pairs of Batch operation signal and arguments. example:
Nota : operations are treated server-side as signal. Batches exposes two signals:
(soon)