tobogganSe connecter

louise

The Louise language: compiler, runtime, std, tooling

Clone avec HTTPS, un jeton personnel en mot de passe, ou avec SSH, une clé ajoutée dans vos paramètres.

NomDernier commitDate
src/Distribution, stage 1: actors across hosts, typed on the wire (#404, ADR 0072)il y a 2 sem.
test/Distribution, stage 1: actors across hosts, typed on the wire (#404, ADR 0072)il y a 2 sem.
louise.tomlDistribution, stage 1: actors across hosts, typed on the wire (#404, ADR 0072)il y a 2 sem.
make-certs.shDistribution, stage 1: actors across hosts, typed on the wire (#404, ADR 0072)il y a 2 sem.
README.mdDistribution, stage 1: actors across hosts, typed on the wire (#404, ADR 0072)il y a 2 sem.
README.MD

A two-node cluster

Node b keeps a key-value store (src/kv.lse) and names it "store" for the cluster. Node a finds it, calls it, starts a worker on node b (src/words.lse, a @remote function), and watches node b until it goes. One build runs as both nodes: its argument says which role, its environment which node. The tutorial's chapter 7 explains the code; ADR 0072 the design.

Distribution is native only, and needs a security review before production use: any node the cluster's authority certified can message, kill and spawn on every other.

Run it

You need the compiler and the runtime (the tutorial's setup), and openssl.

Certificates. Nodes authenticate each other with mutual TLS: each presents a certificate for its own name, from the cluster's authority. make-certs.sh makes an authority and certificates for a.cluster.example and b.cluster.example, valid 30 days, in a directory of your choice (not this one; the keys are secrets in any real cluster):

cd examples/cluster
certs=$(mktemp -d)
./make-certs.sh "$certs"
louise build                       # build/cluster

Node b, in one terminal ([cluster] in louise.toml names the cluster and has it listen on 127.0.0.1:4370):

LOUISE_NODE=b.cluster.example \
LOUISE_CERT=$certs/b.pem LOUISE_KEY=$certs/b.key LOUISE_CA=$certs/ca.pem \
  ./build/cluster store

It prints store: listening on port 4370.

Node a, in another (set certs there too): it listens on another port, and dials node b, its seed:

LOUISE_NODE=a.cluster.example \
LOUISE_CERT=$certs/a.pem LOUISE_KEY=$certs/a.key LOUISE_CA=$certs/ca.pem \
LOUISE_LISTEN=127.0.0.1:4371 LOUISE_SEEDS=b.cluster.example@127.0.0.1:4370 \
  ./build/cluster client b.cluster.example
connected to b.cluster.example
put: None
get: Some("louise")
size: 1
counted 5 words on b.cluster.example
peer: Up, 3 messages sent, 4 received
watching b.cluster.example: stop it to see it go

Stop node b (Ctrl-C). Node a's monitor of the store ends with noconnection, then monitor_node reports the node down:

louise: dist: b.cluster.example: connection closed: end of stream
store: Crashed(noconnection)
b.cluster.example is down

Things to try:

  • Give node a certificates from another authority (make-certs.sh into another directory): both nodes log the refused connection on stderr, node a redials, and gives up after 10 s with the reason dist.peers holds (TLS: invalid peer certificate: BadSignature).
  • Add a constructor to kv.Request, and run that build as node a against the old node b: node b refuses it, built from other types. One cluster runs one build of its types (one schema) in stage 1.

Tested

crates/louise/tests/dist.rs (the_cluster_example_runs_on_two_nodes) runs both nodes with the test certificates of crates/louise/tests/fixtures/tls, kills node b, and checks node a's output; test/kv_test.lse tests the store on one node (louise test).