Struct rnp::PingRunnerCore
source · [−]pub struct PingRunnerCore { /* private fields */ }
Implementations
sourceimpl PingRunnerCore
impl PingRunnerCore
sourcepub fn new(
config: RnpPingRunnerConfig,
stop_event: Arc<ManualResetEvent>
) -> PingRunnerCore
pub fn new(
config: RnpPingRunnerConfig,
stop_event: Arc<ManualResetEvent>
) -> PingRunnerCore
Take the config and stop event and generate the RnpCore which runs all the pings.
Arguments
config
: The configuration of Rnp.stop_event
: The event to signal Rnp to stop.
returns: RnpCore
Examples
use rnp::*;
use std::ops::Range;
use std::time::Duration;
use std::sync::Arc;
use futures_intrusive::sync::ManualResetEvent;
use tokio::runtime::Runtime;
let config = RnpPingRunnerConfig {
worker_config: PingWorkerConfig {
protocol: RnpSupportedProtocol::TCP,
target: "10.0.0.1:443".parse().unwrap(),
source_ip: "10.0.0.2".parse().unwrap(),
ping_interval: Duration::from_millis(1500),
ping_client_config: PingClientConfig {
wait_timeout: Duration::from_millis(1000),
time_to_live: Some(128),
check_disconnect: false,
wait_before_disconnect: Duration::ZERO,
disconnect_timeout: Duration::from_millis(2000),
server_name: None,
log_tls_key: false,
alpn_protocol: None,
use_timer_rtt: false,
},
},
worker_scheduler_config: PingWorkerSchedulerConfig {
source_ports: PortRangeList {
ranges: vec![(1024..=2048), (3096..=3096), (3097..=3097)]
},
ping_count: Some(4),
warmup_count: 1,
parallel_ping_count: 1,
},
result_processor_config: PingResultProcessorConfig {
common_config: PingResultProcessorCommonConfig {
quiet_level: RNP_QUIET_LEVEL_NONE,
},
exit_on_fail: false,
exit_failure_reason: None,
csv_log_path: None,
json_log_path: None,
text_log_path: None,
show_result_scatter: false,
show_latency_scatter: false,
latency_buckets: None,
},
external_ping_client_factory: None,
extra_ping_result_processors: vec![],
};
let rt = Runtime::new().unwrap();
rt.block_on(async {
let stop_event = Arc::new(ManualResetEvent::new(false));
let core = PingRunnerCore::new(config, stop_event);
});
sourcepub async fn run_warmup_pings(&mut self)
pub async fn run_warmup_pings(&mut self)
Run all warm up pings one by one and wait until they are all completed.
sourcepub fn start_running_normal_pings(&mut self)
pub fn start_running_normal_pings(&mut self)
Start running all normal pings in the way that matches the specified config.
Auto Trait Implementations
impl !RefUnwindSafe for PingRunnerCore
impl Send for PingRunnerCore
impl Sync for PingRunnerCore
impl Unpin for PingRunnerCore
impl !UnwindSafe for PingRunnerCore
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
impl<V, T> VZip<V> for Twhere
V: MultiLane<T>,
impl<V, T> VZip<V> for Twhere
V: MultiLane<T>,
fn vzip(self) -> V
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more