pub struct NodeSession { /* private fields */ }
Expand description
Represents a remote connection to a node()
. The NodeSession is the main
handler for all inter-node communication and handles
- The state of the authentication handshake
- Control messages for actor synchronization + group membership changes
RemoteActor
s wishing to send messages to their remote counterparts on the remote system (and receive replies)
A NodeSession can either be a client or server session, depending on the connection sequence. If it was an incoming request to the crate::NodeServer then it’s a “server” session, as the server spawned this actor. Otherwise it’s an outgoing “client” request.
If the NodeSession is a client session, it will start the authentication handshake with
a auth_protocol::NameMessage
announcing this node’s name to the remote system for deduplication
and starting the rest of the handshake. For full authentication pattern details, see
src/protocol/auth.proto
src/node/auth.rs
Lastly the node’s have an intern-node “ping” operation which occurs to keep the TCP session alive and additionally measure peer latency.
Implementations§
Source§impl NodeSession
impl NodeSession
Sourcepub fn new(
node_id: NodeId,
is_server: bool,
cookie: String,
node_server: ActorRef<NodeServerMessage>,
node_name: NameMessage,
connection_mode: NodeConnectionMode,
) -> Self
pub fn new( node_id: NodeId, is_server: bool, cookie: String, node_server: ActorRef<NodeServerMessage>, node_name: NameMessage, connection_mode: NodeConnectionMode, ) -> Self
Construct a new NodeSession with the supplied arguments
node_id
: This peer’s node idis_server
: Is a server-received session (if false, this is the client)cookie
: The authorization cookienode_server
: The parent node servernode_name
: This node’s name and connection detailsconnection_mode
: The connection mode for peer connections
Trait Implementations§
Source§impl Actor for NodeSession
impl Actor for NodeSession
Source§type Msg = NodeSessionMessage
type Msg = NodeSessionMessage
Source§type Arguments = NetworkStream
type Arguments = NetworkStream
Source§type State = NodeSessionState
type State = NodeSessionState
Source§async fn pre_start(
&self,
myself: ActorRef<Self::Msg>,
stream: Self::Arguments,
) -> Result<Self::State, ActorProcessingErr>
async fn pre_start( &self, myself: ActorRef<Self::Msg>, stream: Self::Arguments, ) -> Result<Self::State, ActorProcessingErr>
Source§async fn post_stop(
&self,
myself: ActorRef<Self::Msg>,
_state: &mut Self::State,
) -> Result<(), ActorProcessingErr>
async fn post_stop( &self, myself: ActorRef<Self::Msg>, _state: &mut Self::State, ) -> Result<(), ActorProcessingErr>
post_stop
won’t be called. Read more