View Source Partisan Cheatsheet

The following cheatsheet assumes you have two nodes running: ruby (ruby@127.0.0.1) and max (max@127.0.0.1).

connecting-to-other-peers

Connecting to other peers

manually-joining-using-erlang-s-console

Manually joining using Erlang's console

1. Obtain max's node specification

(max@127.0.0.1)1> NodeSpec = partisan:node_spec().

2. Join ruby with max

(ruby@127.0.0.1)1> NodeSpec = ...
(ruby@127.0.0.1)2> partisan_peer_service:join(NodeSpec).

NodeSpec is the value obtained at max in the previous step.

checking-cluster-membership-view

Checking cluster membership view

Obtain members

(max@127.0.0.1)1> partisan_peer_service:members().

Returns [node_spec()] and should contain both node specifications.

Obtain nodes

(max@127.0.0.1)1> partisan:nodes().

Returns [node()] and should contain both nodes.

sending-messages

Sending messages

obtain-max-s-shell-pid

Obtain max's shell pid

(max@127.0.0.1)2> partisan:self().
<<"partisan:pid:max@127.0.0.1:0.813.0">>

Returns [partisan_remote_ref:t()]. Notice this can be a tuple or a binary (as in the second line of the snippet) depending on the configuration option remote_ref_as_uri.

send-message-from-ruby-to-max

Send message from ruby to max

(ruby@127.0.0.1)3> Ref = <<"partisan:pid:max@127.0.0.1:0.813.0">>.
(ruby@127.0.0.1)4> partisan:forward_message(Ref, hello).

check-the-message-arrived-at-max

Check the message arrived at max

(max@127.0.0.1)3> flush().
Shell got hello
ok