pub struct EntropyReceiver { /* private fields */ }Expand description
Entropy receiver driver.
§Examples
use std::path::PathBuf;
use std::sync::Arc;
use dynomite::entropy::{
receive::RedisReplaySink, EntropyConfig, EntropyReceiver,
};
let cfg = EntropyConfig {
key_file: PathBuf::from("conf/recon_key.pem"),
iv_file: PathBuf::from("conf/recon_iv.pem"),
listen_addr: "127.0.0.1:8105".parse().unwrap(),
send_addr: None,
peer_endpoint: "127.0.0.1:8105".parse().unwrap(),
buffer_size: 16 * 1024,
header_size: 1024,
encrypt: true,
};
let sink = Arc::new(RedisReplaySink::default());
let handle = EntropyReceiver::run(cfg, sink).await.unwrap();
handle.abort();Implementations§
Source§impl EntropyReceiver
impl EntropyReceiver
Sourcepub async fn run(
cfg: EntropyConfig,
sink: BoxedSnapshotSink,
) -> EntropyResult<JoinHandle<EntropyResult<()>>>
pub async fn run( cfg: EntropyConfig, sink: BoxedSnapshotSink, ) -> EntropyResult<JoinHandle<EntropyResult<()>>>
Bind a receiver to cfg.listen_addr and spawn the accept
loop on a tokio task.
Each accepted connection is handled in line on the same
task, mirroring the reference engine’s single-threaded
entropy loop. The returned handle resolves to Ok(()) only
after the listener is shut down (e.g. by aborting the task)
or to an error if the bind fails.
§Errors
Forwards anything from key loading or socket bind.
Sourcepub async fn bind(
cfg: EntropyConfig,
sink: BoxedSnapshotSink,
) -> EntropyResult<Self>
pub async fn bind( cfg: EntropyConfig, sink: BoxedSnapshotSink, ) -> EntropyResult<Self>
Bind without spawning. Used by tests that want to drive the accept loop on the caller’s task.
§Errors
Forwards anything from key loading or socket bind.
Sourcepub fn local_addr(&self) -> Result<SocketAddr>
pub fn local_addr(&self) -> Result<SocketAddr>
Local address the receiver is bound to. Useful for tests
that bind to :0 and then dial the kernel-assigned port.
§Errors
Forwarded from the underlying socket call.
Sourcepub async fn accept_one(self) -> EntropyResult<usize>
pub async fn accept_one(self) -> EntropyResult<usize>
Accept exactly one connection, process it, and return.
§Errors
Forwards I/O, protocol, and crypto errors from the worker.
Sourcepub async fn accept_loop(self) -> EntropyResult<()>
pub async fn accept_loop(self) -> EntropyResult<()>
Accept connections until the task is aborted.
Auto Trait Implementations§
impl !Freeze for EntropyReceiver
impl !RefUnwindSafe for EntropyReceiver
impl Send for EntropyReceiver
impl Sync for EntropyReceiver
impl Unpin for EntropyReceiver
impl UnsafeUnpin for EntropyReceiver
impl !UnwindSafe for EntropyReceiver
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> FutureExt for T
impl<T> FutureExt for T
Source§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
Source§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.