aboutsummaryrefslogtreecommitdiff
path: root/errors.go
diff options
context:
space:
mode:
authorShulhan <ms@kilabit.info>2021-03-21 04:30:07 +0700
committerShulhan <ms@kilabit.info>2021-03-21 04:30:07 +0700
commit05474abb07f73aace79bcf339be8e5619dd4564b (patch)
tree6cd71065014161f3f4f95aacb6b0508ce20a216c /errors.go
parent77e3074ccbbb01945e06d5608d34d5f39352500e (diff)
downloadgorankusu-05474abb07f73aace79bcf339be8e5619dd4564b.tar.xz
all: implement API and interface for attack functionality
When the user click "Attack" it will call the API to run the load testing. If there is load testing currently, it will return with an error. On success, the result of load testing will be stored on directory defined in Environment.ResultsDir with file named <HttpTarget.ID>.<date_time>.<RPS>x<Duration>s.<ResultsSuffix>.bin This file contains the vegeta.Results.
Diffstat (limited to 'errors.go')
-rw-r--r--errors.go23
1 files changed, 23 insertions, 0 deletions
diff --git a/errors.go b/errors.go
index 989561a..faf009c 100644
--- a/errors.go
+++ b/errors.go
@@ -12,6 +12,29 @@ import (
libhttp "github.com/shuLhan/share/lib/http"
)
+func errAttackConflict(ltr *loadTestingResult) error {
+ res := &libhttp.EndpointResponse{
+ E: liberrors.E{
+ Code: http.StatusConflict,
+ Message: "another attack is already running",
+ Name: "ERR_ATTACK_CONFLICT",
+ },
+ Data: ltr,
+ }
+ return res
+}
+
+func errAttackNotAllowed() error {
+ res := &libhttp.EndpointResponse{
+ E: liberrors.E{
+ Code: http.StatusNotAcceptable,
+ Message: "attack is not allowed",
+ Name: "ERR_ATTACK_NOT_ALLOWED",
+ },
+ }
+ return res
+}
+
func errInternal(err error) error {
res := &libhttp.EndpointResponse{
E: liberrors.E{