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
impl UptimeStatus
Main implementation
Sourcepub fn new(success_ratio_target: u8, urls: Vec<String>, timeout: u64) -> Self
pub fn new(success_ratio_target: u8, urls: Vec<String>, timeout: u64) -> Self
§create a new UptimeStatus
and perform it’s check
Sourcepub fn check(&mut self)
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.
Sourcepub fn calc_success(&mut self)
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.