pub struct Step {
pub setup: Setup,
pub ops: Vec<Op>,
pub hold: HoldSpec,
}Expand description
A sequence of ops followed by a hold period.
For non-Loop steps, ops are applied first, then setup cgroups
are created, configured, and populated. For Loop steps, setup
runs once before the ops loop.
Construct via Step::new (ops-only, no setup), Step::with_defs
(cgroup setup + hold), or Step::with_payload (payload-driven step).
For chained mutation of the ops list, Step::set_ops REPLACES
the existing vec — Backdrop’s extend_ops semantics (APPEND) are not
mirrored here because Step is single-phase.
Fields§
§setup: SetupCgroup setup applied before (non-Loop) or once above (Loop)
the ops list. Runtime cgroups are spawned from this spec.
ops: Vec<Op>Ordered operations applied each time the step body runs: cpuset edits, task moves, spawn/despawn, etc.
hold: HoldSpecHow long, and whether to loop, after the ops finish one pass.
Implementations§
Source§impl Step
impl Step
Sourcepub fn new(ops: Vec<Op>, hold: HoldSpec) -> Self
pub fn new(ops: Vec<Op>, hold: HoldSpec) -> Self
Create a step with ops only (no CgroupDef setup). Prefer
this constructor over the struct-literal Step { setup, ops, hold } form — the constructor preserves struct
stability across non_exhaustive field additions
(e.g. future Step::with_* builder methods) and is the
stable surface tracked by Self::with_defs +
Self::hold.
// Common one-liner: spawn workers then hold for 1s.
let s = Step::new(vec![Op::add_cgroup("cg_a"), Op::spawn(...)],
HoldSpec::Fixed(Duration::from_secs(1)));
// For setup-only steps (CgroupDef + spawns) use Step::with_defs.
// For wait-only phases (no ops) use Step::hold.Sourcepub fn hold(hold: HoldSpec) -> Self
pub fn hold(hold: HoldSpec) -> Self
Create a step that applies NO ops and just holds. Sugar for
Step::new(vec![], hold) — the most common shape for “wait
for the workload to settle before the next op” phases in
A/B test scenarios.
Sourcepub fn with_op(op: Op, hold: HoldSpec) -> Self
pub fn with_op(op: Op, hold: HoldSpec) -> Self
Create a step that applies a single op then holds. Sugar for
Step::new(vec![op], hold) — the most common shape for “swap
scheduler / attach scheduler / replace scheduler then hold”
phases in A/B test scenarios.
Sourcepub fn with_defs(defs: Vec<CgroupDef>, hold: HoldSpec) -> Self
pub fn with_defs(defs: Vec<CgroupDef>, hold: HoldSpec) -> Self
Create a step with CgroupDef setup and a hold period.
Most steps only need cgroup definitions and a hold duration.
Use set_ops to chain ops onto the step.
Sourcepub fn set_ops(self, ops: Vec<Op>) -> Self
pub fn set_ops(self, ops: Vec<Op>) -> Self
Replace the ops for a step, consuming and returning it.
Named set_ops rather than extend_ops because the semantics
are REPLACE, not EXTEND — contrast
Backdrop::extend_ops,
which appends. A chained Step::new(ops).set_ops(more)
drops ops and keeps only more.
Sourcepub const fn set_hold(self, hold: HoldSpec) -> Self
pub const fn set_hold(self, hold: HoldSpec) -> Self
Replace the hold spec for a step, consuming and returning it.
Sibling of set_ops — both REPLACE a single
field. Bare-verb set_ prefix matches set_ops for
prefix-consistency within Step; the convention reserves
with_X for alternative constructors (see with_defs,
with_payload).
Sourcepub fn with_payload(payload: &'static Payload, hold: HoldSpec) -> Self
pub fn with_payload(payload: &'static Payload, hold: HoldSpec) -> Self
Create a step that spawns a single userspace
Payload binary in the
background and holds for the given duration before teardown.
Shorthand for Step::new(vec![Op::run_payload(payload, vec![])], hold). The returned step is chainable — add
.set_ops(...) to replace the ops vec (note the
REPLACE-not-EXTEND semantics), or use
Op::wait_payload(name) / Op::kill_payload(name) on later
steps to control the spawned child.
Test authors who want the payload placed in a named cgroup
should use Op::run_payload_in_cgroup directly; this
convenience targets the common “one payload, whole step”
shape.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Step
impl RefUnwindSafe for Step
impl Send for Step
impl Sync for Step
impl Unpin for Step
impl UnwindSafe for Step
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more