pub struct EntropySender;Expand description
Entropy sender driver.
Operationally, calling run spawns a
tokio task that performs one push and then exits.
§Examples
use std::path::PathBuf;
use std::sync::Arc;
use dynomite::entropy::{
EntropyConfig, EntropySender, RedisLocalSnapshot,
};
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 source = Arc::new(RedisLocalSnapshot::default());
let handle = EntropySender::run(cfg, source);
handle.await.unwrap().unwrap();Implementations§
Source§impl EntropySender
impl EntropySender
Sourcepub fn run(
cfg: EntropyConfig,
source: BoxedSnapshotSource,
) -> JoinHandle<EntropyResult<usize>>
pub fn run( cfg: EntropyConfig, source: BoxedSnapshotSource, ) -> JoinHandle<EntropyResult<usize>>
Spawn a tokio task that performs one snapshot push.
The returned JoinHandle resolves to the push result.
The task uses cfg.peer_endpoint to dial the receiver and
cfg.send_addr (when set) for the local bind.
Sourcepub async fn push(
cfg: EntropyConfig,
source: BoxedSnapshotSource,
) -> EntropyResult<usize>
pub async fn push( cfg: EntropyConfig, source: BoxedSnapshotSource, ) -> EntropyResult<usize>
Perform one snapshot push and return the number of plaintext bytes transferred. Used directly by tests; the spawned variant just calls this on a tokio task.
§Errors
Forwards anything from key loading, source acquisition, dialing, or transport.
Sourcepub async fn push_with_material(
cfg: EntropyConfig,
source: BoxedSnapshotSource,
override_material: Option<EntropyMaterial>,
) -> EntropyResult<usize>
pub async fn push_with_material( cfg: EntropyConfig, source: BoxedSnapshotSource, override_material: Option<EntropyMaterial>, ) -> EntropyResult<usize>
Perform one snapshot push using a pre-loaded
EntropyMaterial.
When override_material is None and cfg.encrypt is
set, key + IV bytes are loaded from cfg.key_file /
cfg.iv_file (the historical behaviour). When
override_material is Some(_), the supplied material is
used verbatim and the on-disk paths are not touched. The
override is consumed by the crate::entropy::driver::EntropyDriver
run loop, which loads the AES material once at startup
and drives many cycles from the same handle.
§Errors
Forwards anything from key loading (when no override is supplied), source acquisition, dialing, or transport.
Auto Trait Implementations§
impl Freeze for EntropySender
impl RefUnwindSafe for EntropySender
impl Send for EntropySender
impl Sync for EntropySender
impl Unpin for EntropySender
impl UnsafeUnpin for EntropySender
impl UnwindSafe for EntropySender
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.