Trait goose::config::GooseDefaultType
source · [−]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
):
GooseDefault::DebugLog
GooseDefault::ErrorLog
GooseDefault::GooseLog
GooseDefault::HatchRate
GooseDefault::Host
GooseDefault::ManagerBindHost
GooseDefault::ManagerHost
GooseDefault::ReportFile
GooseDefault::RequestLog
GooseDefault::ScenarioLog
GooseDefault::Scenarios
GooseDefault::TelnetHost
GooseDefault::TestPlan
GooseDefault::Timeout
GooseDefault::TransactionLog
GooseDefault::WebSocketHost
The following run-time options can be configured with a custom default using a
usize
integer:
GooseDefault::Users
GooseDefault::StartupTime
GooseDefault::RunTime
GooseDefault::Iterations
GooseDefault::RunningMetrics
GooseDefault::LogLevel
GooseDefault::Quiet
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::NoPrintMetrics
GooseDefault::NoMetrics
GooseDefault::NoTransactionMetrics
GooseDefault::NoScenarioMetrics
GooseDefault::RequestBody
GooseDefault::NoErrorSummary
GooseDefault::NoDebugBody
GooseDefault::NoTelnet
GooseDefault::NoWebSocket
GooseDefault::NoAutoStart
GooseDefault::NoGzip
GooseDefault::NoStatusCodes
GooseDefault::StickyFollow
GooseDefault::Manager
GooseDefault::Worker
GooseDefault::NoHashCheck
GooseDefault::NoGranularData
The following run-time flags can be configured with a custom default using a
GooseLogFormat
.
GooseDefault::RequestFormat
GooseDefault::TransactionFormat
GooseDefault::ScenarioFormat
GooseDefault::ErrorFormat
GooseDefault::DebugFormat
The following run-time flags can be configured with a custom default using a
GooseCoordinatedOmissionMitigation
.
Required Methods
sourcefn 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)?
// 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(())
}