-
Notifications
You must be signed in to change notification settings - Fork 2
Home
Nexus is an asynchronous lightweight message broker. It allows two (or more) different non-connected components to interchange data between them.
It supports different communication paradigms:
- RPC: where the listener waits for the sender to trigger an execution, and the sender waits for a response for the message.
- Pub/Sub: where the sender does not care about any response caused by the message.
Nexus is backed by RethinkDB, which implements a reactive paradigm, being the foundation for all Nexus realtime capabilities.
Currently there are quite a few message broker solutions in the market, so, why did we develop Nexus?
The main characteristic of Nexus is that its protocol is based in JSON-RPC, using different channels to connect to the broker (WebSocket, TCP, HTTP and the SSL variations of them), making it platform agnostic, as today any platform is capable of using any of these channels and speak JSON.
Pull
$ ncat localhost 1717
>>> {"jsonrpc":"2.0", "method": "sys.login", "params": {"user": "root", "pass": "root"}, "id":1}
<<< {"jsonrpc":"2.0", "result":{"connid":"a126920cd1344042","ok":true,"user":"root"}, "id":1}
>>> {"jsonrpc":"2.0", "method": "task.pull", "params": {"prefix": "nexus.srv.hello", "timeout": 60}, "id": 2}
...
<<< {"jsonrpc":"2.0", "result":{"detach":false, "method":"hi","params":{"text":"Hello world!"},"path":"nexus.srv.hello.","prio":0,"tags":{"@admin":true},"taskid":"a126920c756a6ae847ed10bb52e8ed05d7e5","user":"root"}}
>>> {"jsonrpc":"2.0", "method": "task.result", "params": {"taskid": "a126920c756a6ae847ed10bb52e8ed05d7e5", "result": "Hi there!"}, "id": 3}
<<< {"jsonrpc":"2.0","id":3,"result":{"ok":true}}
Push
$ ncat localhost 1717
>>> {"jsonrpc":"2.0", "method": "sys.login", "params": {"user": "root", "pass": "root"}, "id":1}
<<< {"jsonrpc":"2.0","id":1,"result":{"connid":"a126920c756a6ae8","ok":true,"user":"root"}}
>>> {"jsonrpc":"2.0", "method": "task.push", "params": {"method": "nexus.srv.hello.hi", "params": {"text": "Hello world!"}}, "id": 2}
...
<<< {"jsonrpc":"2.0","id":2,"result":"Hi there!"}
Nexus is develop in Go, but we have implemented client layers for other languages, so the developer does not need to worry about protocol details, using a high level abstraction to interoperate with any other software, no matter the language the other peer is implemented in.
The reference implentation for the client layers is implemented in Go, and usually this will be the one with one step forward, and the rest will be catching up.
Here you will find the reference API: https://github.com/jaracil/nexus/blob/master/API.md
- Client: https://github.com/jaracil/nxpy
- Sugar: github.com/nayarsystems/nxsugar-py
This is a transpilation of the Go client using GopherJS, so they both are always aligned.