[][src]Function health::check_future

pub fn check_future<F, X, E>(name: impl Into<String>, f: F) -> FutureCheck<F> where
    F: Fn() -> X + Send + Sync + 'static,
    X: Future<Output = Result<(), E>> + Send + Sync + 'static,
    E: StdError + Send + Sync + 'static, 

Wraps an asynchronous function as a checkable source for health checks

Example

use health::Checkable;

async fn all_is_well() -> Result<(), Error> { Ok(()) }
async fn everything_is_fire() -> Result<(), Error> { Err(Error {}) }

let always_ok = health::check_future("ok", all_is_well);
assert_eq!(Ok(()), block_on(always_ok.check()));

let always_err = health::check_future("err", everything_is_fire);
assert_eq!(Err(Error {}), block_on(always_err.check()));