mythsunwind / mls-server

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

mls-server

A prototype MLS server. See https://github.com/wireapp/melissa.

Running

First build the project: make build. Then:

In-memory storage

  • make run to run the server
  • make test to test the server

Cassandra storage

Ensure that Cassandra is running on port 9042.

  • make schema run-db to run the server
  • make schema-test test-db to test the server

API

All endpoints accept and return JSON, unless stated otherwise.

Schema

The server stores blobs. A Blob has the following schema:

{
    "index"   : int >= 0,
    "content" : JSON
}

GET /groups/:id/blobs

For a group, get a list of all blobs in some range, from oldest to newest.

Parameters:

Name    Type Description
:id Any string Group ID.
?from Int (optional) The beginning of the range (inclusive). If this parameter is not specified, enumeration will start from the first blob.
?to Int (optional) The end of the range (exclusive). If this parameter is not specified, enumeration will proceed until the last blob.

Returns:

Status Return type Description
200 Array of Blobs An array with requested blobs. Can be empty.
400 - The range is outside of the allowed range [0; len), or the lower bound of the range is higher than the upper bound.

Error schema:

// The range is outside of the allowed range
{
    "tag": "BlobRangeOutOfBounds",
    "description": "...",
    "body":
        {
            "allowed_range": {"from": int, "to": int},
            "requested_range": {"from": int, "to": int}
        }
}
// The lower bound of the range is higher than the upper bound
{
    "tag": "InvalidBlobRange",
    "description": "...",
    "body":
        {
            "requested_range": {"from": int, "to": int}
        }
}

POST /groups/:id/blobs

Append a new blob to the list of blobs belonging to the group. If the group didn't exist before, it will be created.

Blob indices have to go in order, starting from 0:

  • If the previous blob has index N, the one posted to this endpoint has to have index N+1.

  • If there are no blobs, the posted blob has to have index 0.

Parameters:

Name Type Description
:id Any string Group ID.
Body Blob The blob that should be appended to the list.

Returns:

Status Return type Description
204 - The blob has been appended.
400 - The blob has the wrong index.

Error schema:

// The blob has the wrong index
{
    "tag": "UnexpectedBlobIndex",
    "description": "...",
    "body":
        {
            "expected_index": int,
            "got_index": int
        }
}

POST /i/reset

Clear all storage. An internal endpoint.

Returns:

Status Return type Description
204 - The storage has been cleared.

About

License:GNU Affero General Public License v3.0


Languages

Language:Haskell 91.2%Language:Dockerfile 5.0%Language:Makefile 3.8%