diff --git a/src/core/connection.rs b/src/core/connection.rs index b468fae..57526d4 100644 --- a/src/core/connection.rs +++ b/src/core/connection.rs @@ -21,8 +21,11 @@ pub mod request_connection; type ConnectionRegister = Vec + Send + Sync>>; -pub(crate) enum ConnectionEnum { +/// Connection +pub enum ConnectionEnum { + /// Configuration of the connection Config(ConnectionConfig), + /// Active connection Active(ActiveConnection), } diff --git a/src/core/connection/outbound_connection.rs b/src/core/connection/outbound_connection.rs index 9c9a4f6..3604aee 100644 --- a/src/core/connection/outbound_connection.rs +++ b/src/core/connection/outbound_connection.rs @@ -4,9 +4,13 @@ use crate::core::{outbound::GenericConnection, Activate}; use super::{ConnectionEnum, ConnectionRegister}; -pub(crate) struct ConnectionConfig { +/// Connection configuration +pub struct ConnectionConfig { + /// List of connections pub connection_register: ConnectionRegister, + /// Launch pad for new connections pub maybe_register_launch_pad: Option>>, + /// Landing pad for new connections pub maybe_register_landing_pad: Option>>, } @@ -22,6 +26,7 @@ impl Drop for ConnectionConfig { } impl ConnectionConfig { + /// pub fn new() -> Self { let (connection_launch_pad, connection_landing_pad) = tokio::sync::oneshot::channel(); Self { @@ -32,16 +37,21 @@ impl ConnectionConfig { } } -pub(crate) struct ActiveConnection { +/// Active connection +pub struct ActiveConnection { + /// List of connections pub maybe_registers: Option>, + /// Landing pad for new connections pub maybe_register_landing_pad: Option>>, } impl ConnectionEnum { + /// new connection pub fn new() -> Self { Self::Config(ConnectionConfig::new()) } + /// push connection pub fn push(&mut self, connection: Arc + Send + Sync>) { match self { Self::Config(config) => { diff --git a/src/core/outbound.rs b/src/core/outbound.rs index 2a279ab..541e68d 100644 --- a/src/core/outbound.rs +++ b/src/core/outbound.rs @@ -36,10 +36,11 @@ pub struct OutboundChannel { pub name: String, /// Name of the actor that sends the outbound messages. pub actor_name: String, - pub(crate) connection_register: ConnectionEnum, + /// register + pub connection_register: ConnectionEnum, } -impl OutboundChannel { +impl OutboundChannel { /// Create a new outbound for actor in provided context. pub fn new(context: &mut Context, name: String, actor_name: &str) -> Self { context.assert_unique_outbound_name(name.clone(), actor_name); @@ -137,7 +138,9 @@ impl Debug for OutboundConnectionWithAdapter: Send + Sync { +/// Generic connection trait +pub trait GenericConnection: Send + Sync { + /// Send a message to the connected inbound channels to other actors. fn send_impl(&self, msg: T); }