exit early if disabled, or setup throttle
@@ -1098,16 +1098,18 @@ impl GooseAttack {
// A channel used by parent to tell throttle the load test is complete.
Option<mpsc::Sender<bool>>,
) {
- match self.configuration.throttle_requests {
- // Throttle is not configured, return immediately.
- None => (None, None),
- Some(throttle_requests) => {
+ // If the throttle isn't configured, return immediately.
+ if self.configuration.throttle_requests.is_none() {
+ return (None, None);
+ }
+
+ // Unwrap is safe here as we exit early if the throttle isn't configured.
+ let throttle_requests = self.configuration.throttle_requests.unwrap();
+
// Create a bounded channel allowing single-sender multi-receiver to throttle
// GooseUser threads.
- let (all_threads_throttle, throttle_receiver): (
- mpsc::Sender<bool>,
- mpsc::Receiver<bool>,
- ) = mpsc::channel(throttle_requests);
+ let (all_threads_throttle, throttle_receiver): (mpsc::Sender<bool>, mpsc::Receiver<bool>) =
+ mpsc::channel(throttle_requests);
// Create a channel allowing the parent to inform the throttle thread when the
// load test is finished. Even though we only send one message, we can't use a
@@ -1130,8 +1132,6 @@ impl GooseAttack {
(Some(all_threads_throttle), Some(parent_to_throttle_tx))
}
- }
- }
/// Called internally in local-mode and gaggle-mode.
async fn launch_users(
