Federation is the process of sending messages to a peer that does not live (not connected) to the same relay as the sender. In rmb any one can deploy and host a relay server safely since a relay can't inspect the message payload itself (well, once EndToEnd encryption is implemented) the rmb network can (will) eventually be consisted of multiple relay servers (please check docs)
Scenario
Assume Peer1 (P1) and Peer (P2) are connect to Relay 1 (R1) and Relay 2 (R2) respectively.
If P1 need to send message to P2 what happens is, the envelope need to hold the "full address" of the destination Peer (P2).
Before P1 send a message to P2 it already knows everything about it (like it's public key) so it already know P2 relay domain
P1 creates an Envelope with destination (P2) and federation (R2).
P1 pushes the message to (R1) normally like any other message.
R1 will check and see that the envelope has R2 in the federation information that does not match it's own domain.
R1 then will need to push the message to R2
Technical specs
each relay will have an HTTP endpoint /federation
When a valid envelope is POSTED to this endpoint, the federation information will be checked. The federation information must match the relay domain, otherwise an error is returned.
If the federation information match, the message is pushed internally to be switched to the designated twin.
If a peer pushes a message to the Relay (over their web-socket connection)
The relay checks the federation information, this can be 1 of the following 2 cases:
empty, federation (not set) or has a value equal to the relay domain (say R1) then message is switched itnernally
federation information that is foreign, the message is scheduled for federation to the proper relay (say R2)
If federation is decided the following should happen:
message is pushed to a special federation redis queue (say relay.federation)
A worker pool will keep popping the messages (number of workers need to be configurable)
A worker will keep trying posting this message to https://R2/federation
some errors are terminal, other errors can be retried
If worker failed to send the message to remote relay, an error message is sent back to the caller.
Some work has already been done on the federation branch, it's trivial but shows where things need to go.
Federation is the process of sending messages to a peer that does not live (not connected) to the same relay as the sender. In rmb any one can deploy and host a relay server safely since a relay can't inspect the message payload itself (well, once EndToEnd encryption is implemented) the rmb network can (will) eventually be consisted of multiple relay servers (please check docs)
Scenario
Technical specs
/federation
https://R2/federation