rnp

Struct PingRunnerCore

Source
pub struct PingRunnerCore { /* private fields */ }

Implementations§

Source§

impl PingRunnerCore

Source

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);
});
Source

pub async fn run_warmup_pings(&mut self)

Run all warm up pings one by one and wait until they are all completed.

Source

pub fn start_running_normal_pings(&mut self)

Start running all normal pings in the way that matches the specified config.

Source

pub async fn join(&mut self)

Wait for all pings to complete.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

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
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more