aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2024-02-21 01:45:56 +0700
committerShulhan <ms@kilabit.info>2024-02-21 01:45:56 +0700
commite8d3716995e9229a61a32894689c379e22475420 (patch)
tree9c20154a220d9110cd09574fe0092e62e3fac8eb
parentf8b6b66d9b407f7441a9170b46e42d928532f732 (diff)
downloadgorankusu-e8d3716995e9229a61a32894689c379e22475420.tar.xz
all: move constants declaration closer to its usage
-rw-r--r--attack_options.go13
-rw-r--r--environment.go12
-rw-r--r--gorankusu.go17
-rw-r--r--http_server.go5
4 files changed, 30 insertions, 17 deletions
diff --git a/attack_options.go b/attack_options.go
index 6f53613..369afef 100644
--- a/attack_options.go
+++ b/attack_options.go
@@ -9,6 +9,19 @@ import (
vegeta "github.com/tsenart/vegeta/v12/lib"
)
+// DefaultAttackDuration define default attack duration per Target.
+// This is default value for [AttackOptions.Duration].
+const DefaultAttackDuration = 10 * time.Second
+
+// DefaultAttackRatePerSecond define default attack rate per second per
+// Target.
+// This is default value for [AttackOptions.RatePerSecond].
+const DefaultAttackRatePerSecond = 500
+
+// DefaultAttackTimeout define default timeout for each attack request.
+// This is default value for [AttackOptions.Timeout].
+const DefaultAttackTimeout = 30 * time.Second
+
// AttackOptions define the options for attacking HTTP endpoint.
type AttackOptions struct {
// Duration define the duration for each attack to be executed,
diff --git a/environment.go b/environment.go
index d8625ec..6b88b3e 100644
--- a/environment.go
+++ b/environment.go
@@ -10,6 +10,18 @@ import (
"time"
)
+// DefaultListenAddress define default gorankusu server address.
+const DefaultListenAddress = `127.0.0.1:8217`
+
+// DefaultMaxAttackDuration define maximum duration attack can run on
+// all Target.
+// This is default value for [Environment.MaxAttackDuration].
+const DefaultMaxAttackDuration = 30 * time.Second
+
+// DefaultMaxAttackRate define maximum rate an attack can run.
+// This is default value for [Environment.MaxAttackRate].
+const DefaultMaxAttackRate = 3000
+
// Environment contains global configuration for load testing.
type Environment struct {
// AttackRunning will be set to non-nil if there is a load
diff --git a/gorankusu.go b/gorankusu.go
index dd6f9f1..b8aec82 100644
--- a/gorankusu.go
+++ b/gorankusu.go
@@ -8,7 +8,6 @@ import (
"net/http"
"os"
"strings"
- "time"
vegeta "github.com/tsenart/vegeta/v12/lib"
@@ -20,26 +19,10 @@ import (
// Version of gorankusu module.
const Version = `0.5.0`
-// List of default values.
-const (
- DefaultAttackDuration = 10 * time.Second
- DefaultAttackRatePerSecond = 500
- DefaultAttackTimeout = 30 * time.Second
- DefaultMaxAttackDuration = 30 * time.Second
- DefaultMaxAttackRate = 3000
-
- DefaultListenAddress = `127.0.0.1:8217`
-)
-
// EnvDevelopment setting this environment variable will enable gorankusu
// development mode.
const EnvDevelopment = "GORANKUSU_DEV"
-// List of HTTP parameters.
-const (
- paramNameName = "name"
-)
-
// Gorankusu is the HTTP server with web user interface and APIs for running and
// load testing the registered HTTP endpoints.
type Gorankusu struct {
diff --git a/http_server.go b/http_server.go
index e0ed45d..3c0a77f 100644
--- a/http_server.go
+++ b/http_server.go
@@ -25,6 +25,11 @@ const (
pathAPITargets = `/_gorankusu/api/targets`
)
+// List of HTTP parameters.
+const (
+ paramNameName = "name"
+)
+
// List of HTTP APIs provided by Gorankusu HTTP server.
var (
apiEnvironmentGet = &libhttp.Endpoint{