Struct goose::goose::GooseTaskSet[][src]

pub struct GooseTaskSet {
    pub name: String,
    pub task_sets_index: usize,
    pub weight: usize,
    pub task_wait: Option<(Duration, Duration)>,
    pub tasks: Vec<GooseTask>,
    pub weighted_tasks: Vec<(usize, String)>,
    pub weighted_on_start_tasks: Vec<(usize, String)>,
    pub weighted_on_stop_tasks: Vec<(usize, String)>,
    pub host: Option<String>,
}
Expand description

An individual task set.

Fields

name: String

The name of the task set.

task_sets_index: usize

An integer reflecting where this task set lives in the internal GooseAttack.task_sets vector.

weight: usize

An integer value that controls the frequency that this task set will be assigned to a user.

task_wait: Option<(Duration, Duration)>

A Duration range defining the minimum and maximum time a GooseUser should sleep after running a task.

tasks: Vec<GooseTask>

A vector containing one copy of each GooseTask that will run by users running this task set.

weighted_tasks: Vec<(usize, String)>

A fully scheduled and weighted vector of integers (pointing to GooseTasks and GooseTask names.

weighted_on_start_tasks: Vec<(usize, String)>

A vector of vectors of integers, controlling the sequence and order on_start GooseTasks are run when the user first starts.

weighted_on_stop_tasks: Vec<(usize, String)>

A vector of vectors of integers, controlling the sequence and order on_stop GooseTasks are run when the user first starts.

host: Option<String>

An optional default host to run this GooseTaskSet against.

Implementations

Creates a new GooseTaskSet. Once created, a GooseTask must be assigned to it, and finally it must be registered with the GooseAttack object. The returned object must be stored in a mutable value.

Example
use goose::prelude::*;

let mut example_tasks = taskset!("ExampleTasks");

Registers a GooseTask with a GooseTaskSet, where it is stored in the GooseTaskSet.tasks vector. The function associated with the task will be run during the load test.

Example
use goose::prelude::*;

let mut example_tasks = taskset!("ExampleTasks");
example_tasks.register_task(task!(a_task_function));

/// A very simple task that loads the "a" page.
async fn a_task_function(user: &mut GooseUser) -> GooseTaskResult {
    let _goose = user.get("a/").await?;

    Ok(())
}

Sets a weight on a task set. The larger the value of weight, the more often the task set will be assigned to users. For example, if you have task set foo with a weight of 3, and task set bar with a weight of 1, and you spin up a load test with 8 users, 6 of them will be running the foo task set, and 2 will be running the bar task set.

Example
use goose::prelude::*;

#[tokio::main]
async fn main() -> Result<(), GooseError> {
    let mut example_tasks = taskset!("ExampleTasks").set_weight(3)?;

    Ok(())
}

Set a default host for the task set. If no --host flag is set when running the load test, this host will be pre-pended on all requests. For example, this can configure your load test to run against your local development environment by default, and the --host option could be used to override host when running the load test against production.

Example
use goose::prelude::*;

let mut example_tasks = taskset!("ExampleTasks").set_host("http://10.1.1.42");

Configure a task_set to to pause after running each task. The length of the pause will be randomly selected from min_wait to max_wait inclusively.

Example
use goose::prelude::*;
use std::time::Duration;

#[tokio::main]
async fn main() -> Result<(), GooseError> {
    taskset!("ExampleTasks").set_wait_time(Duration::from_secs(0), Duration::from_secs(1))?;

    Ok(())
}

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Convert Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>. Box<dyn Any> can then be further downcast into Box<ConcreteType> where ConcreteType implements Trait. Read more

Convert Rc<Trait> (where Trait: Downcast) to Rc<Any>. Rc<Any> can then be further downcast into Rc<ConcreteType> where ConcreteType implements Trait. Read more

Convert &Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &Any’s vtable from &Trait’s. Read more

Convert &mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot generate &mut Any’s vtable from &mut Trait’s. Read more

Convert Arc<Trait> (where Trait: Downcast) to Arc<Any>. Arc<Any> can then be further downcast into Arc<ConcreteType> where ConcreteType implements Trait. Read more

Performs the conversion.

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more

Instruments this type with the current Span, returning an Instrumented wrapper. Read more

Performs the conversion.

Should always be Self

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more