Function fail::cfg
[−]
[src]
pub fn cfg<S: Into<String>>(name: S, actions: &str) -> Result<(), String>
Set new actions to a fail point at runtime.
The format of actions is action[->action...]
. When multiple actions are specified,
an action will be checked only when its former action is not triggered.
The format of an action is [p%][cnt*]task[(arg)]
. p%
is the expected probability that
the action is triggered, and cnt*
is the max times the action can be triggered.
Supported task
includes:
off
, the fail point will do nothing.return(arg)
, return early when the fail point is triggered.arg
is passed to$e
( defined via thefail_point!
macro) as a string.sleep(milliseconds)
, sleep for the specified time.panic(msg)
, panic with the message.print(msg)
, print the message.pause
, sleep until other action is set to the fail point.yield
, yield the CPU.delay(milliseconds)
, busy waiting for the specified time.
For example, 20%3*print(still alive!)->panic
means the fail point has 20% chance to print a
message "still alive!" and 80% chance to panic. And the message will be printed at most 3
times.