Trait goose::config::GooseDefaultType [−][src]
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-GooseTaskSet
host is defined, no
--host
CLI option is configured, and if
the GooseTask
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
):
GooseDefault::Host
GooseDefault::GooseLog
GooseDefault::RequestFormat
GooseDefault::TaskLog
GooseDefault::ErrorLog
GooseDefault::DebugLog
GooseDefault::TelnetHost
GooseDefault::WebSocketHost
GooseDefault::ManagerBindHost
GooseDefault::ManagerHost
The following run-time options can be configured with a custom default using a
usize
integer:
GooseDefault::Users
GooseDefault::HatchRate
GooseDefault::StartupTime
GooseDefault::RunTime
GooseDefault::RunningMetrics
GooseDefault::LogLevel
GooseDefault::Verbose
GooseDefault::ThrottleRequests
GooseDefault::ExpectWorkers
GooseDefault::TelnetPort
GooseDefault::WebSocketPort
GooseDefault::ManagerBindPort
GooseDefault::ManagerPort
The following run-time flags can be configured with a custom default using a
bool
(and otherwise default to false
).
GooseDefault::NoResetMetrics
GooseDefault::NoMetrics
GooseDefault::NoTaskMetrics
GooseDefault::RequestBody
GooseDefault::NoErrorSummary
GooseDefault::NoDebugBody
GooseDefault::NoTelnet
GooseDefault::NoWebSocket
GooseDefault::NoAutoStart
GooseDefault::NoGzip
GooseDefault::StatusCodes
GooseDefault::StickyFollow
GooseDefault::Manager
GooseDefault::NoHashCheck
GooseDefault::Worker
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
fn set_default(
self,
key: GooseDefault,
value: T
) -> Result<Box<Self>, GooseError>
fn set_default(
self,
key: GooseDefault,
value: T
) -> Result<Box<Self>, GooseError>
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)?
// Display info level logs while the test runs.
.set_default(GooseDefault::Verbose, 1)?
// Log all requests made during the test to `./goose-request.log`.
.set_default(GooseDefault::RequestLog, "goose-request.log")?;
Ok(())
}