pub trait GooseDefaultType<T> {
    fn set_default(
        self,
        key: GooseDefault,
        value: T
    ) -> Result<Box<Self>, GooseError>; }
Expand description

Most run-time options can be programmatically configured with custom defaults.

For example, you can optionally configure a default host for the load test. This is used if no per-Scenario host is defined, no --host CLI option is configured, and if the Transaction itself doesn’t hard-code the host in the base url of its request. In that case, this host is added to all requests.

In the following example, the load test is programmatically configured with GooseDefaultType::set_default to default to running against a local development container. The --host run time option can be used at start time to override the host value, and the GooseControllerCommand::host Controller command can be used to change the host value of an AttackPhase::idle load test.

Example

use goose::prelude::*;

#[tokio::main]
async fn main() -> Result<(), GooseError> {
    GooseAttack::initialize()?
        .set_default(GooseDefault::Host, "local.dev")?;

    Ok(())
}

The following run-time options can be configured with a custom default using a borrowed string slice (&str):

The following run-time options can be configured with a custom default using a usize integer:

The following run-time flags can be configured with a custom default using a bool (and otherwise default to false).

The following run-time flags can be configured with a custom default using a GooseLogFormat.

The following run-time flags can be configured with a custom default using a GooseCoordinatedOmissionMitigation.

Required Methods

Sets a GooseDefault to the provided value. The required type of each option is documented in GooseDefaultType.

Example
use goose::prelude::*;

#[tokio::main]
async fn main() -> Result<(), GooseError> {
    GooseAttack::initialize()?
        // Do not reset the metrics after the load test finishes starting.
        .set_default(GooseDefault::NoResetMetrics, true)?
        // Do not display info level logs while the test runs.
        .set_default(GooseDefault::Quiet, 1)?
        // Log all requests made during the test to `./goose-request.log`.
        .set_default(GooseDefault::RequestLog, "goose-request.log")?;

    Ok(())
}

Implementors