pyrlang.dist_proto.base_dist_protocol¶
Base abstract Distribution connection class
- class pyrlang.dist_proto.base_dist_protocol.BaseDistProtocol(node_name)¶
Bases:
ProtocolDefines Erlang distribution protocol (shared parts). Concrete implementations for incoming (DistServerProtocol) and outgoing (DistClientProtocol) are located in the corresponding modules.
- DISCONNECTED = 'disconn'¶
- CONNECTED = 'conn'¶
- RECV_NAME = 'recvname'¶
- WAIT_ALIVE_REPLY = 'wait_alive_reply'¶
- WAIT_CHALLENGE_REPLY = 'wait_ch_reply'¶
- RECV_STATUS = 'recv_status'¶
- RECV_CHALLENGE = 'recv_challenge'¶
- RECV_CHALLENGE_ACK = 'recv_challenge_ack'¶
- node_db = <pyrlang.node_db.NodeDB object>¶
- node_name_¶
Name of the running Erlang node.
- packet_len_size_¶
Packet size header is variable, 2 bytes before handshake is finished and 4 bytes afterwards.
- state_¶
FSM state for the protocol state-machine.
- unconsumed_data_¶
Received bytes that are not handled yet: not a whole packet, or reading is paused.
- backlog_bytes_¶
Messages from this connection, and their bytes, that wait in process inboxes (the receive backlog).
- max_backlog_bytes_¶
Reading pauses at these; set from the node when connected.
- reading_paused_¶
Reading is paused because the backlog is full.
- writable_¶
Set unless the transport asked us to stop writing (
pause_writing): its buffer is over the busy limit.
- tick_interval_¶
Seconds between two ticks: net_ticktime / TICK_INTENSITY.
- silent_ticks_¶
Ticks in a row during which the peer sent nothing.
- incoming_¶
The peer’s atom cache and unfinished fragmented messages; replaced when the handshake has settled the flags.
- send_headers_¶
Packets start with a distribution header instead of ‘p’.
- send_fragments_¶
Large payloads are sent in fragments.
- sequence_counter_¶
Sequence id of the last message sent (used if it is fragmented).
- destroy()¶
Close the connection; safe to call more than once.
- pause_writing()¶
The transport’s buffer is over the busy limit (callback).
- resume_writing()¶
The transport’s buffer is below its low-water mark (callback).
- async wait_writable()¶
Wait while the transport’s buffer is over the busy limit.
- backlog_add(nbytes)¶
A message from this connection was put into a process inbox.
- backlog_release(nbytes)¶
A process took a message from this connection out of its inbox (or exited without taking it).
- connection_made(transport)¶
Connection has been accepted and established (callback).
- data_received(data)¶
Bytes from the peer: split them into packets and handle each. A malformed packet closes the connection.
- on_packet(data)¶
Handle one packet of the handshake.
- Returns:
False to close the connection
- Return type:
- get_node()¶
Use this to get access to the Pyrlang node which owns this protocol. :rtype: pyrlang2.node.Node
- connection_lost(_exc)¶
Handler is called when the client has disconnected
- on_passthrough_message(control_term, msg_term)¶
Act on a control message that
control.check_controlaccepted (so its number, arity and element types are right) and its message. Synchronous, so that the signals of a connection take effect in the order they arrived; signals for other nodes are queued, not waited for.
- send_command(m)¶
Send a signal to the peer now:
("send", From, To, Msg),("link", From, To), … (see_write_command). Dropped if the connection is closing: the peer’s processes seenoconnection.
- static make_digest(challenge, cookie)¶
The MD5 digest that answers
challengewithcookie.
- raise_protocol_error(msg)¶
Give up the connection because of what the peer sent.
- Raises:
DistributionError – always
- static check_digest(digest, challenge, cookie)¶
Hash cookie + the challenge together producing a verification hash and return if they match against the offered ‘digest’.
- on_packet_connected(data)¶
Handle incoming dist packets in the connected state.
- report_dist_connected()¶
The handshake is over: register the connection with the node and start ticking.