From 082ea71bfc4619e9d84b5fdcf689be30871da326 Mon Sep 17 00:00:00 2001 From: "Alexander A. Klimov" Date: Sun, 13 Oct 2019 17:03:17 +0200 Subject: [PATCH] Outsource v1.Load --- rest.go | 11 ++--------- v1/load.go | 11 +++++++++++ 2 files changed, 13 insertions(+), 9 deletions(-) create mode 100644 v1/load.go diff --git a/rest.go b/rest.go index b1c4057..9b3e7c8 100644 --- a/rest.go +++ b/rest.go @@ -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" @@ -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(), diff --git a/v1/load.go b/v1/load.go new file mode 100644 index 0000000..e374829 --- /dev/null +++ b/v1/load.go @@ -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"` +}