pub fn cfg<S: Into<String>>(
registry: Arc<FailPointRegistry>,
name: S,
actions: &str,
) -> Result<(), String>Expand description
Configure the actions for a fail point at runtime.
Each fail point can be configured with a series of actions, specified by the
actions argument. 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 a single 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. The supported values of task are:
off, the fail point will do nothing.return(arg), return early when the fail point is triggered.argis 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), log the message, using thelogcrate, at theinfolevel.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.
The FAILPOINTS environment variable accepts this same syntax for its fail
point actions.
A call to cfg with a particular fail point name overwrites any existing actions for
that fail point, including those set via the FAILPOINTS environment variable.