Here is a demo of the first (very simple) version of the message router.
This assumes you have a working ocaml/opam/dune setup. Hit me up (or @nemael or @arie perhaps) if you don’t have this … the 3 of us use a Debian-based system and it’s fairly straightforward.
I’m using OCaml v.4.11.0
opam update
cd /your/sources/dir
git clone git@gitlab.com:public.dream/libs/ocaml-seaboar
cd ocaml-seaboar
opam install --with-test .
cd /your/sources/dir
git clone git@gitlab.com:public.dream/upsycle/message-router
cd message-router
git reset --hard fd3c8ac1c44db08d2dd182a6278fe28273b293c2
git submodule update --init --recursive
opam install --deps-only .
dune build
# --- this will generate certificates and store them in a .gitignore'd directory -- these shouldn't be checked in to git
bin/gen-certs
If you happen to have services running on :6000, :6001, or :7000 on your machine, change the values in conf/config-*.yaml
Run the demo executable:
bin/run-msg-router
The message router contains a state which currently simply stores the number of messages processed and the routing table. Press S
to see the state. It starts with two fake routes; see conf/config-message-router.yaml
Press ‘m’ to simulate a message being received. This is a so-called ‘listen message’ (now obsolete I think), which services send to the message router to announce themselves. It consists of a simple header and a body containing the routing information of the service. It is encoded as CBOR and encoded/decoded using our CBOR library. Each one contains a random pubkey and a random IPv4 address and port.
Press S
to see the state.
Press s
to serialise the state to a file as CBOR (default: /tmp/upsycle-state.cbor
). This will be necessary later if the message router is restarted. This also uses our CBOR library.
Press n
to simulate a message which uses the pubkey of the first entry in the routing table (sorted alphanumerically) and a new route: this simulates an existing service announcing that it’s changing its routing information.
Press m
to send some more messages, heck, press M
to send 1000 messages at a time.
Press r
to restore the state to its former version. There should be just one message processed and 3 routes.
In a separate terminal (don’t try to background the process using Ctrl-Z – this won’t work because reasons), run bin/run-service 1
. This will a run mock service (think of this as one of the other unikernels, e.g. dmc or one of the pub-sub services), and register itself with the message router over TLS. You should see a new route in the routing table of the message router. The message router will also send a message back to the service through the newly established route over TLS: ‘hi there’.
You can also run a second service using bin/run-service 2