pyrlang.dist_proto.control

Messages of an established connection, as pure functions over bytes: splitting a packet’s content into control message and payload, and checking the control message’s shape (“Protocol between Connected Nodes” in erl_dist_protocol). A peer’s bytes are untrusted: everything wrong raises DistributionError, and the caller closes that connection.

pyrlang.dist_proto.control.spawn_options(options)

What the option list of a checked SPAWN_REQUEST asks for.

Returns:

(link, monitor), or None if an option is not one a node may send (the request is then answered with the error badopt)

Return type:

tuple[bool, bool] | None

pyrlang.dist_proto.control.plain_form(control, message)

A checked control message and its payload reduced to the few forms the node acts on: an exit reason sent as payload goes back into the control tuple (24-28 become EXIT, EXIT2, MONITOR_P_EXIT), trace tokens are dropped (see without_token()), and an alternate action signal (37) becomes the send or EXIT2 it stands for; its priority is dropped, and the receiver of such an EXIT2 may be an alias or a name.

Returns:

control message, and the message or None

Return type:

tuple[tuple[Any, …], Any]

pyrlang.dist_proto.control.without_token(control)

The token-free form of a checked control message: this node does not take part in sequential tracing, so the token of a _TT message is dropped and the message handled as its plain counterpart.

pyrlang.dist_proto.control.split_message(data, atoms, options)

Split a control message with its optional payload into the decoded control term and the payload’s bytes.

Parameters:
Returns:

control term, and the encoded payload or None if there is none

Return type:

tuple[Any, bytes | None]

pyrlang.dist_proto.control.decode_payload(payload, atoms, options)

The message that follows a control message; nothing may follow it.

pyrlang.dist_proto.control.check_control(control, has_payload)

Check a control message’s number, arity, element types and whether it may or must carry a payload.

Returns:

True if this node acts on the message, False if it is a valid message of the protocol that is to be dropped

Return type:

bool