pub fn reachable(url: &str, budget: Duration) -> ServiceAvailabilityExpand description
Does something accept a connection at url within budget?
Only the authority of the URL is used, and only when its host is an IP literal:
resolving a name would be a network call, and this runs on a shell prompt. A refused
connection is ServiceAvailability::NotRunning — the port is free, so nothing is
there. Anything else, expiry included, is ServiceAvailability::Unknown, because a
probe that did not finish has not learnt that a service is down.
use majordomus_cli::environment::probe::authority;
assert_eq!(authority("http://127.0.0.1:8741"), Some(("127.0.0.1".to_string(), 8741)));
assert_eq!(authority("http://127.0.0.1:8741/docs"), Some(("127.0.0.1".to_string(), 8741)));
assert_eq!(authority("http://example.test:80"), Some(("example.test".to_string(), 80)));
assert_eq!(authority("not a url"), None);