Struct ractor_cluster::node::node_session::NodeSession
source · 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
§type Msg = NodeSessionMessage
type Msg = NodeSessionMessage
§type Arguments = NetworkStream
type Arguments = NetworkStream
§type State = NodeSessionState
type State = NodeSessionState
source§fn pre_start<'life0, 'async_trait>(
&'life0 self,
myself: ActorRef<Self::Msg>,
stream: Self::Arguments
) -> Pin<Box<dyn Future<Output = Result<Self::State, ActorProcessingErr>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn pre_start<'life0, 'async_trait>(
&'life0 self,
myself: ActorRef<Self::Msg>,
stream: Self::Arguments
) -> Pin<Box<dyn Future<Output = Result<Self::State, ActorProcessingErr>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
source§fn post_stop<'life0, 'life1, 'async_trait>(
&'life0 self,
myself: ActorRef<Self::Msg>,
_state: &'life1 mut Self::State
) -> Pin<Box<dyn Future<Output = Result<(), ActorProcessingErr>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn post_stop<'life0, 'life1, 'async_trait>(
&'life0 self,
myself: ActorRef<Self::Msg>,
_state: &'life1 mut Self::State
) -> Pin<Box<dyn Future<Output = Result<(), ActorProcessingErr>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
post_stop
won’t be called. Read more