diff options
| author | Shulhan <ms@kilabit.info> | 2021-03-21 04:30:07 +0700 |
|---|---|---|
| committer | Shulhan <ms@kilabit.info> | 2021-03-21 04:30:07 +0700 |
| commit | 05474abb07f73aace79bcf339be8e5619dd4564b (patch) | |
| tree | 6cd71065014161f3f4f95aacb6b0508ce20a216c /errors.go | |
| parent | 77e3074ccbbb01945e06d5608d34d5f39352500e (diff) | |
| download | gorankusu-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.go | 23 |
1 files changed, 23 insertions, 0 deletions
@@ -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{ |
