Struct UptimeStatus

Source
pub struct UptimeStatus {
    pub success: bool,
    pub success_ratio: u8,
    pub success_ratio_target: u8,
    pub reachable: usize,
    pub urls: Vec<String>,
    pub timeout: u64,
}
Expand description

§Describes an uptime status

UptimeStatus describes the result of an uptime check.

Fields§

§success: bool

true if the UptimeStatus is considered successful

§success_ratio: u8

the percentage of reachable urls out of the total urls

§success_ratio_target: u8

the percentage of reachable urls out of the total urls that need to be reachable in order for this UptimeStatus to be considered a success.

§reachable: usize

the number of reachable urls

§urls: Vec<String>

which urls to check in check()

§timeout: u64

timeout length for requests (in ms)

Implementations§

Source§

impl UptimeStatus

Main implementation

Source

pub fn new(success_ratio_target: u8, urls: Vec<String>, timeout: u64) -> Self

§create a new UptimeStatus and perform it’s check
Source

pub fn check(&mut self)

§check for success with the given urls

Makes the actual https requests and updates fields accordingly.

Note: Blocking execution for all requests, timeout is set to REQUEST_TIMEOUT.

Source

pub fn calc_success(&mut self)

§calculate the success based on the reachable and total

Calculates the ratio of reachable / (length of urls).

Calculates a success_ratio (as u8) from that, by multiplying with 100, then flooring.

If the success_ratio is greater than or equal to the success_ratio_target, the UptimeStatus will be considered a success.

In the special case that no URLs to check for have been provided, the check will be considered a success, but the success_ratio will be 0.

Note: does not check for networking, use check() for that.

Trait Implementations§

Source§

impl Debug for UptimeStatus

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for UptimeStatus

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Display for UptimeStatus

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Serialize for UptimeStatus

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. Read more
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<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
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> ErasedDestructor for T
where T: 'static,

Source§

impl<T> MaybeSendSync for T