-
Notifications
You must be signed in to change notification settings - Fork 2
/
performance-test.go
52 lines (40 loc) · 1.23 KB
/
performance-test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
package api
import (
"log"
"net/http"
"strconv"
"github.com/archway-network/valuter/tasks"
"github.com/archway-network/valuter/tools"
routing "github.com/julienschmidt/httprouter"
)
/*----------------------*/
/*
* This function implements GET /challenges/uptime
*/
func GetPerformanceTestWinners(resp http.ResponseWriter, req *http.Request, params routing.Params) {
winnersList, err := tasks.GetPerformanceTestWinners()
if err != nil {
log.Printf("Error in db query: %v", err)
http.Error(resp, "Internal Server Error: "+err.Error(), http.StatusInternalServerError)
return
}
tools.SendJSON(resp, winnersList.GetItems())
}
/*-------------*/
/*
* This function implements GET /challenges/uptime/:burst_index
*/
func GetPerformanceTestWinnersPerLoadBurst(resp http.ResponseWriter, req *http.Request, params routing.Params) {
burstIndex, err := strconv.Atoi(params.ByName("burst_index"))
if err != nil {
burstIndex = 0
}
winnersList, err := tasks.GetPerformanceTestWinnersPerLoadBurst(burstIndex)
if err != nil {
log.Printf("Error in db query: %v", err)
http.Error(resp, "Internal Server Error: "+err.Error(), http.StatusInternalServerError)
return
}
tools.SendJSON(resp, winnersList.GetItems())
}
/*-------------*/