pub fn command<I, O, E>(
config: Config,
function: CommandFn<I, O, E>
) -> Result<Command<I, O, E>, CriusError>where
E: From<CriusError>,
Expand description
Use this function to construct a circuit breaker without a fallback function.
Example:
// Define a simple circuit breaker command:
let mut cmd = command(Config::default(), |n| {
if n > 10 {
Err(ExampleError)
} else {
Ok(n * 2)
}}).unwrap();
// and run it with an example input:
let result = cmd.run(10);
assert_eq!(Ok(20), result)