async fn requests(
    topic: String,
    payload_size: usize,
    count: usize,
    client: AsyncClient,
    qos: QoS,
    delay: u64,
) {
    let mut interval = match delay {
        0 => None,
        delay => Some(time::interval(time::Duration::from_millis(delay))),
    };

    for i in 0..count {
        let payload = vec![0; payload_size];
        if let Some(interval) = &mut interval {
            interval.tick().await;
        }

        // These errors are usually due to eventloop task being dead. We can ignore the
        // error here as the failed eventloop task would have already printed an error
        if let Err(_e) = client.publish(topic.as_str(), qos, false, payload).await {
            break;
        }

        info!("published {}", i);
    }

    if qos == QoS::AtMostOnce {
        let payload = vec![0; payload_size];
        if let Err(_e) = client
            .publish(topic.as_str(), QoS::AtLeastOnce, false, payload)
            .await
        {
            return;
        }
    }
}
/// make count number of requests at specified QoS.
make count number of requests at specified QoS.
make count number of requests at specified QoS .
async fn requests(
    topic: String,
    payload_size: usize,
    count: usize,
    client: AsyncClient,
    qos: QoS,
    delay: u64,
) {
    let mut interval = match delay {
        0 => None,
        delay => Some(time::interval(time::Duration::from_millis(delay))),
    };
    for i in 0..count {
        let payload = vec![0; payload_size];
        if let Some(interval) = &mut interval {
            interval.tick().await;
        }
        // These errors are usually due to eventloop task being dead. We can ignore the
        // error here as the failed eventloop task would have already printed an error
        if let Err(_e) = client.publish(topic.as_str(), qos, false, payload).await {
            break;
        }
        info!("published {}", i);
    }
    if qos == QoS::AtMostOnce {
        let payload = vec![0; payload_size];
        if let Err(_e) = client
            .publish(topic.as_str(), QoS::AtLeastOnce, false, payload)
            .await
        {
            return;
        }
    }
}
async fn requests ( topic : String , payload_size : usize , count : usize , client : AsyncClient , qos : QoS , delay : u64 , ) { let mut interval = match delay { 0 => None , delay => Some ( time :: interval ( time :: Duration :: from_millis ( delay ) ) ) , } ; for i in 0 .. count { let payload = vec ! [ 0 payload_size ] ; if let Some ( interval ) = & mut interval { interval . tick ( ) . await ; } // These errors are usually due to eventloop task being dead. We can ignore the // error here as the failed eventloop task would have already printed an error if let Err ( _e ) = client . publish ( topic . as_str ( ) , qos , false , payload ) . await { break ; } info ! ( " " i ) ; } if qos == QoS :: AtMostOnce { let payload = vec ! [ 0 payload_size ] ; if let Err ( _e ) = client . publish ( topic . as_str ( ) , QoS :: AtLeastOnce , false , payload ) . await { return ; } } }
make count number of requests at specified QoS.
make count number of requests at specified QoS .
topic
String
payload_size
usize
count
usize
client
AsyncClient
qos
QoS
delay
u64