use super::{
Arc, AtomTable, CONNECTION_READY_ATOM, CONNECTION_SHUTDOWN_CONTROL_ATOM, ConnectionNotifier,
ConnectionRuntime, ConnectionRuntimeInstallation, ConnectionServiceInstallation,
ConnectionServices, LimitsConfig, PassVerifier, Weak,
};
impl ConnectionRuntime {
#[cfg(test)]
pub(in crate::server::connection) fn for_tests(services: Arc<dyn ConnectionServices>) -> Self {
let atoms = AtomTable::with_common_atoms();
let control_atom = atoms.intern(CONNECTION_SHUTDOWN_CONTROL_ATOM);
let ready_atom = atoms.intern(CONNECTION_READY_ATOM);
Self::new(
ConnectionRuntimeInstallation {
services: ConnectionServiceInstallation::capture(services),
incarnations: None,
fatal_shutdown: None,
},
control_atom,
ready_atom,
Weak::new(),
None,
(None, None),
LimitsConfig::default(),
)
}
#[cfg(test)]
pub(in crate::server::connection) fn for_tests_with_limits(
services: Arc<dyn ConnectionServices>,
limits: LimitsConfig,
) -> Self {
let atoms = AtomTable::with_common_atoms();
let control_atom = atoms.intern(CONNECTION_SHUTDOWN_CONTROL_ATOM);
let ready_atom = atoms.intern(CONNECTION_READY_ATOM);
Self::new(
ConnectionRuntimeInstallation {
services: ConnectionServiceInstallation::capture(services),
incarnations: None,
fatal_shutdown: None,
},
control_atom,
ready_atom,
Weak::new(),
None,
(None, None),
limits,
)
}
#[cfg(test)]
pub(in crate::server::connection) fn for_tests_with_auth_token(
services: Arc<dyn ConnectionServices>,
token: Vec<u8>,
) -> Self {
let atoms = AtomTable::with_common_atoms();
let control_atom = atoms.intern(CONNECTION_SHUTDOWN_CONTROL_ATOM);
let ready_atom = atoms.intern(CONNECTION_READY_ATOM);
Self::new(
ConnectionRuntimeInstallation {
services: ConnectionServiceInstallation::capture(services),
incarnations: None,
fatal_shutdown: None,
},
control_atom,
ready_atom,
Weak::new(),
None,
(Some(token), None),
LimitsConfig::default(),
)
}
#[cfg(test)]
pub(in crate::server::connection) fn for_tests_with_notifier(
services: Arc<dyn ConnectionServices>,
notifier: Arc<dyn ConnectionNotifier>,
) -> Self {
let atoms = AtomTable::with_common_atoms();
let control_atom = atoms.intern(CONNECTION_SHUTDOWN_CONTROL_ATOM);
let ready_atom = atoms.intern(CONNECTION_READY_ATOM);
Self::new(
ConnectionRuntimeInstallation {
services: ConnectionServiceInstallation::capture(services),
incarnations: None,
fatal_shutdown: None,
},
control_atom,
ready_atom,
Weak::new(),
Some(notifier),
(None, None),
LimitsConfig::default(),
)
}
#[cfg(test)]
pub(in crate::server::connection) fn for_tests_with_pass(
services: Arc<dyn ConnectionServices>,
notifier: Arc<dyn ConnectionNotifier>,
token: Option<Vec<u8>>,
verifier: PassVerifier,
) -> Self {
let atoms = AtomTable::with_common_atoms();
let control_atom = atoms.intern(CONNECTION_SHUTDOWN_CONTROL_ATOM);
let ready_atom = atoms.intern(CONNECTION_READY_ATOM);
Self::new(
ConnectionRuntimeInstallation {
services: ConnectionServiceInstallation::capture(services),
incarnations: None,
fatal_shutdown: None,
},
control_atom,
ready_atom,
Weak::new(),
Some(notifier),
(token, Some(verifier)),
LimitsConfig::default(),
)
}
}