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

pub struct GooseTaskSet {
    pub name: String,
    pub task_sets_index: usize,
    pub weight: usize,
    pub min_wait: usize,
    pub max_wait: usize,
    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
Expand description

The name of the task set.

task_sets_index: usize
Expand description

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

weight: usize
Expand description

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

min_wait: usize
Expand description

An integer value indicating the minimum number of seconds a user will sleep after running a task.

max_wait: usize
Expand description

An integer value indicating the maximum number of seconds a user will sleep after running a task.

tasks: Vec<GooseTask>
Expand description

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

weighted_tasks: Vec<(usize, String)>
Expand description

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

weighted_on_start_tasks: Vec<(usize, String)>
Expand description

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)>
Expand description

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

host: Option<String>
Expand description

An optional default host to run this GooseTaskSet against.

Implementations

impl GooseTaskSet[src]

pub fn new(name: &str) -> Self[src]

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");

pub fn register_task(self, task: GooseTask) -> Self[src]

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: &GooseUser) -> GooseTaskResult {
    let _goose = user.get("/a/").await?;

    Ok(())
}

pub fn set_weight(self, weight: usize) -> Result<Self, GooseError>[src]

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::*;

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

    Ok(())
}

pub fn set_host(self, host: &str) -> Self[src]

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");

pub fn set_wait_time(
    self,
    min_wait: usize,
    max_wait: usize
) -> Result<Self, GooseError>
[src]

Configure a task_set to to pause after running each task. The length of the pause will be randomly selected from min_weight to max_wait inclusively. For example, if min_wait is 0 and max_weight is 2, the user will randomly sleep for 0, 1 or 2 seconds after each task completes.

Example

use goose::prelude::*;

fn main() -> Result<(), GooseError> {
    taskset!("ExampleTasks").set_wait_time(0, 1)?;

    Ok(())
}

Trait Implementations

impl Clone for GooseTaskSet[src]

fn clone(&self) -> GooseTaskSet[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Hash for GooseTaskSet[src]

fn hash<__H: Hasher>(&self, state: &mut __H)[src]

Feeds this value into the given Hasher. Read more

fn hash_slice<H>(data: &[Self], state: &mut H) where
    H: Hasher
1.3.0[src]

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

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T> Instrument for T[src]

fn instrument(self, span: Span) -> Instrumented<Self>[src]

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

fn in_current_span(self) -> Instrumented<Self>[src]

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

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

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

pub fn clone_into(&self, target: &mut T)[src]

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

recently added

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

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.

impl<V, T> VZip<V> for T where
    V: MultiLane<T>, 

pub fn vzip(self) -> V