Skip to content

Commit

Permalink
Outsource v1.Load
Browse files Browse the repository at this point in the history
  • Loading branch information
Al2Klimov committed Oct 13, 2019
1 parent 48d657e commit 082ea71
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 9 deletions.
11 changes: 2 additions & 9 deletions rest.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"github.com/kataras/iris"
"github.com/kataras/iris/context"
v1 "github.com/masif-upgrader/agent/v1"
"github.com/masif-upgrader/common"
log "github.com/sirupsen/logrus"
"net"
Expand All @@ -26,15 +27,7 @@ func startRestServer(sock string) (*iris.Application, error) {
}

func getV1Load(context context.Context) {
context.JSON(&struct {
Query [3]float64 `json:"query"`
Install [3]float64 `json:"install"`
Update [3]float64 `json:"update"`
Configure [3]float64 `json:"configure"`
Remove [3]float64 `json:"remove"`
Purge [3]float64 `json:"purge"`
Error [3]float64 `json:"error"`
}{
context.JSON(&v1.Load{
queryStats.queryLoad(),
actionsStats[common.PkgMgrInstall].queryLoad(),
actionsStats[common.PkgMgrUpdate].queryLoad(),
Expand Down
11 changes: 11 additions & 0 deletions v1/load.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package v1

type Load struct {
Query [3]float64 `json:"query"`
Install [3]float64 `json:"install"`
Update [3]float64 `json:"update"`
Configure [3]float64 `json:"configure"`
Remove [3]float64 `json:"remove"`
Purge [3]float64 `json:"purge"`
Error [3]float64 `json:"error"`
}

0 comments on commit 082ea71

Please sign in to comment.