Sign inSign up

raphexion/minimonkey

By raphexion

•Updated about 7 years ago

Image
0

269

raphexion/minimonkey repository overview

⁠Mini Monkey (pre-alpha)

Build Status codecov.io Docker build License Apache 2

Logo

Mini Monkey is a minimal message routing system. Considerably smaller and simpler than MQTT⁠. Like other message brokers (RabbitMQ, EMQX, VerneMQ), Mini Monkey is implemented in Erlang.

⁠Quick Start

docker run -d -p 1773:1773 -e god_token=myToken raphexion/minimonkey

⁠Clients

⁠Project Plan

  • Streamline debug/error messages
  • Add benchmark tests
  • Add more tests concerning permissions
  • Add more examples in README
  • Death Message

⁠Three perspectives

When designing Mini Monkey we need to focus on our three main uses-cases:

  1. A embedded device produces data and is remotely controllable.
  2. A controller is cosuming data from one or more producers and send control messages.
  3. An administrator configures (programmaticially) who can publish/subscribe.

Three perspectives

⁠Design decisions

Mini Monkey is a publish / subscribe broker than only support routing keys (called rooms). Especially it does not implement topics.

Mini Monkey only cares about routing blobs. Especially it does not use JSON / Protocol-buffers or other serialization.

Mini Monkey is designed around small payloads.

Mini Monkey is desgined to be very simple and concise. The goal is to reach feature-completion fast and leave as much as possible outside the broker. The protocol and architecture should be so easy that anyone can implement a client in under and hour.

Mini Monkey uses stateful connections where previous commands affect future commands. The reasons is to keep all payloads small.

⁠Bootstrap and the God Token

Then Mini Monkey starts it will read the environment variable god_token. The purpose is to have one token that can bootstrap the broker. This token can be used to provision the broker and the routing keys (rooms).

VariableComment
god_tokenA token that has all rights

⁠Port

Mini Monkey only uses one port 1773. Connections are made over TCP/IP.

PortComment
1773Controllers, Devices and Administrators

⁠Death Message

Sometimes it is good to communicate when a user disappears. It is therefore (not implemented yet) to set a message, that will be delivered if the user disconnects unexpected.

⁠Protocal

All messages, both to and from the server follow a trivial binary protocol.

SizeComment
1 bitBig endian size?
7 bitsFunction Code
2 bytesPayload size
N bytesOptional payload

⁠Function Codes

CodeCommentPayload meaning
0x00Reseved for future use
0x01Authenticate with tokenToken
0x02Enter room (persistent until changed or reconnect)Room
0x03Publish binary payloadPublished data
0x04Subscribe to current roomTag
0x10Add admin permissions for tokenAdditional admin token in room
0x11Revoke admin permissions for tokenToken to be revoked
0x12Add publish permissions for tokenAdditional publish token in room
0x13Revoke publish permissions for tokenToken to be revoked
0x14Add subscription permissions for tokenAdditional subs. token in room
0x15Revoke subscription permissions for tokenToken to be revoked
0x16Add loginAdditional token that can login
0x17Revoke loginRevoke a token for login
0x20Set death message payloadData that is sent when disconnect
0x21Set death message roomRoom where the messages is published
0x22Enable death message
0x23Disable death message
0x30Forward messages in this room to another roomDestiantion room for forward
0x31Unforward message in this room to anther roomDestionation room for un-forward
0x7EError messageMessage
0x7FDebug messageMessage

⁠Examples

A client logins in and publish 3 messages:

PurposeBytes (little endian)Optional PayloadComment
Auth with token0x01 0x04 0x000x41 0x42 0x43 0x44Token: ABCD
Enter room0x02 0x03 0x000x51 0x52 0x53Key: QRS
Publish0x03 0x04 0x000x01 0x02 0x03 0x04 0x05Binary payload
Publish0x03 0x02 0x000xFF 0xEEBinary payload
Pick another0x02 0x04 0x000x51 0x52 0x53 0x032Key: QRS2
Publish0x03 0x01 0x000xABBinary payload

Tag summary

Content type

Image

Digest

Size

26.1 MB

Last updated

about 7 years ago

docker pull raphexion/minimonkey