[][src]Struct goose::GooseAttack

pub struct GooseAttack { /* fields omitted */ }

Internal global state for load test.

Implementations

impl GooseAttack[src]

Goose's internal global state.

pub fn initialize() -> GooseAttack[src]

Load configuration from command line and initialize a GooseAttack.

Example

    use goose::prelude::*;

    let mut goose_attack = GooseAttack::initialize();

pub fn initialize_with_config(config: GooseConfiguration) -> GooseAttack[src]

Initialize a GooseAttack with an already loaded configuration. This should only be called by worker instances.

Example

    use goose::{GooseAttack, GooseConfiguration};
    use structopt::StructOpt;

    let configuration = GooseConfiguration::from_args();
    let mut goose_attack = GooseAttack::initialize_with_config(configuration);

pub fn initialize_logger(&self)[src]

pub fn setup(self) -> Self[src]

pub fn register_taskset(self, taskset: GooseTaskSet) -> Self[src]

A load test must contain one or more GooseTaskSets. Each task set must be registered into Goose's global state with this method for it to run.

Example

    use goose::prelude::*;

    GooseAttack::initialize()
        .register_taskset(taskset!("ExampleTasks")
            .register_task(task!(example_task))
        )
        .register_taskset(taskset!("OtherTasks")
            .register_task(task!(other_task))
        );

    async fn example_task(client: &GooseClient) {
      let _response = client.get("/foo");
    }

    async fn other_task(client: &GooseClient) {
      let _response = client.get("/bar");
    }

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

Optionally define a task to run before clients are started and all task sets start running. This is would generally be used to set up anything required for the load test.

When running in a distributed Gaggle, this task is only run one time by the Manager.

Example

    use goose::prelude::*;

    GooseAttack::initialize()
        .test_start(task!(setup));

    async fn setup(client: &GooseClient) {
        // do stuff to set up load test ...
    }

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

Optionally define a task to run after all clients have finished running all defined task sets. This would generally be used to clean up anything that was specifically set up for the load test.

When running in a distributed Gaggle, this task is only run one time by the Manager.

Example

    use goose::prelude::*;

    GooseAttack::initialize()
        .test_stop(task!(teardown));

    async fn teardown(client: &GooseClient) {
        // do stuff to tear down the load test ...
    }

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

Optionally configure a default host for the load test. This is used if no per-GooseTaskSet host is defined, no --host CLI option is configurared, and if the GooseTask itself doesn't hard-code the host in its request. The host is prepended on all requests.

For example, your load test may default to running against your local development container, and the --host option could be used to override host to run the load test against production.

Example

    use goose::prelude::*;

    GooseAttack::initialize()
        .set_host("local.dev");

pub fn execute(self)[src]

Execute the load test.

Example

    use goose::prelude::*;

    GooseAttack::initialize()
        .register_taskset(taskset!("ExampleTasks")
            .register_task(task!(example_task).set_weight(2))
            .register_task(task!(another_example_task).set_weight(3))
        )
        .execute();

    async fn example_task(client: &GooseClient) {
      let _response = client.get("/foo");
    }

    async fn another_example_task(client: &GooseClient) {
      let _response = client.get("/bar");
    }

Trait Implementations

impl Clone for GooseAttack[src]

Auto Trait Implementations

Blanket Implementations

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

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

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

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

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

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

type Owned = T

The resulting type after obtaining ownership.

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.

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.

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