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.