ing
This commit is contained in:
parent
904de16326
commit
1d13feb9ce
19
Gopkg.lock
generated
19
Gopkg.lock
generated
|
@ -24,22 +24,21 @@
|
||||||
name = "git.loafle.net/commons/server-go"
|
name = "git.loafle.net/commons/server-go"
|
||||||
packages = [
|
packages = [
|
||||||
".",
|
".",
|
||||||
"client",
|
|
||||||
"socket",
|
"socket",
|
||||||
|
"socket/client",
|
||||||
"socket/web",
|
"socket/web",
|
||||||
"socket/web/client"
|
"socket/web/client"
|
||||||
]
|
]
|
||||||
revision = "1cae23cf7819d56fd399346a1dc30af6a82d1a93"
|
revision = "cbe8e30db48a21b33650c5ed7e7d8bbf4784c9d4"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
branch = "master"
|
branch = "master"
|
||||||
name = "git.loafle.net/commons/util-go"
|
name = "git.loafle.net/commons/util-go"
|
||||||
packages = [
|
packages = [
|
||||||
"context",
|
"context",
|
||||||
"encoding/json",
|
|
||||||
"reflect"
|
"reflect"
|
||||||
]
|
]
|
||||||
revision = "4d4017d214d2a8fdde59d774254f421991fabe7e"
|
revision = "dd4f956c587b1947f84ad5eebd64722b3d6c5224"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
name = "github.com/BurntSushi/toml"
|
name = "github.com/BurntSushi/toml"
|
||||||
|
@ -60,8 +59,8 @@
|
||||||
"gzip",
|
"gzip",
|
||||||
"zlib"
|
"zlib"
|
||||||
]
|
]
|
||||||
revision = "6c8db69c4b49dd4df1fff66996cf556176d0b9bf"
|
revision = "5fb1f31b0a61e9858f12f39266e059848a5f1cea"
|
||||||
version = "v1.2.1"
|
version = "v1.3.0"
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
name = "github.com/klauspost/cpuid"
|
name = "github.com/klauspost/cpuid"
|
||||||
|
@ -69,12 +68,6 @@
|
||||||
revision = "ae7887de9fa5d2db4eaa8174a7eff2c1ac00f2da"
|
revision = "ae7887de9fa5d2db4eaa8174a7eff2c1ac00f2da"
|
||||||
version = "v1.1"
|
version = "v1.1"
|
||||||
|
|
||||||
[[projects]]
|
|
||||||
name = "github.com/klauspost/crc32"
|
|
||||||
packages = ["."]
|
|
||||||
revision = "cb6bfca970f6908083f26f39a79009d608efd5cd"
|
|
||||||
version = "v1.1"
|
|
||||||
|
|
||||||
[[projects]]
|
[[projects]]
|
||||||
name = "github.com/valyala/fasthttp"
|
name = "github.com/valyala/fasthttp"
|
||||||
packages = [
|
packages = [
|
||||||
|
@ -118,6 +111,6 @@
|
||||||
[solve-meta]
|
[solve-meta]
|
||||||
analyzer-name = "dep"
|
analyzer-name = "dep"
|
||||||
analyzer-version = 1
|
analyzer-version = 1
|
||||||
inputs-digest = "80d314f2263e6dd751c17b988048abe6f8eeff450d7088f3fa98cc4873205681"
|
inputs-digest = "d416b3a82f6ebf912d00317b9f2cdf91db9d10dbaef9354ac4bfbdb34c25a63f"
|
||||||
solver-name = "gps-cdcl"
|
solver-name = "gps-cdcl"
|
||||||
solver-version = 1
|
solver-version = 1
|
||||||
|
|
|
@ -33,10 +33,6 @@
|
||||||
branch = "master"
|
branch = "master"
|
||||||
name = "git.loafle.net/commons/server-go"
|
name = "git.loafle.net/commons/server-go"
|
||||||
|
|
||||||
[[constraint]]
|
|
||||||
branch = "master"
|
|
||||||
name = "git.loafle.net/commons/util-go"
|
|
||||||
|
|
||||||
[[constraint]]
|
[[constraint]]
|
||||||
name = "github.com/google/gopacket"
|
name = "github.com/google/gopacket"
|
||||||
version = "1.1.14"
|
version = "1.1.14"
|
||||||
|
|
|
@ -1,9 +1,72 @@
|
||||||
package data
|
package data
|
||||||
|
|
||||||
import "git.loafle.net/overflow/commons-go/core/util"
|
import (
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
|
||||||
|
"git.loafle.net/overflow/commons-go/core/util"
|
||||||
|
)
|
||||||
|
|
||||||
type Metric struct {
|
type Metric struct {
|
||||||
SensorConfigID string `json:"sensorConfigID,omitempty"`
|
SensorID string `json:"sensorID,omitempty"`
|
||||||
|
StartDate *util.Timestamp `json:"startDate,omitempty"`
|
||||||
|
EndDate *util.Timestamp `json:"endDate,omitempty"`
|
||||||
|
Status MetricStatusEnum `json:"status,omitempty"`
|
||||||
|
Extra map[string]string `json:"extra,omitempty"`
|
||||||
Data map[string]string `json:"data,omitempty"`
|
Data map[string]string `json:"data,omitempty"`
|
||||||
CollectDate *util.Timestamp `json:"collectDate,omitempty"`
|
}
|
||||||
|
|
||||||
|
type MetricStatusEnum int
|
||||||
|
|
||||||
|
const (
|
||||||
|
MetricStatusEnumOK MetricStatusEnum = iota + 1
|
||||||
|
MetricStatusEnumINFO
|
||||||
|
MetricStatusEnumWARN
|
||||||
|
MetricStatusEnumERROR
|
||||||
|
MetricStatusEnumCRITICAL
|
||||||
|
)
|
||||||
|
|
||||||
|
var (
|
||||||
|
metricStatusEnumID = map[MetricStatusEnum]string{
|
||||||
|
MetricStatusEnumOK: "OK",
|
||||||
|
MetricStatusEnumINFO: "INFO",
|
||||||
|
MetricStatusEnumWARN: "WARN",
|
||||||
|
MetricStatusEnumERROR: "ERROR",
|
||||||
|
MetricStatusEnumCRITICAL: "CRITICAL",
|
||||||
|
}
|
||||||
|
|
||||||
|
metricStatusEnumKey = map[string]MetricStatusEnum{
|
||||||
|
"OK": MetricStatusEnumOK,
|
||||||
|
"INFO": MetricStatusEnumINFO,
|
||||||
|
"WARN": MetricStatusEnumWARN,
|
||||||
|
"ERROR": MetricStatusEnumERROR,
|
||||||
|
"CRITICAL": MetricStatusEnumCRITICAL,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
|
||||||
|
func (e MetricStatusEnum) String() string {
|
||||||
|
return metricStatusEnumID[e]
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e MetricStatusEnum) MarshalJSON() ([]byte, error) {
|
||||||
|
value, ok := metricStatusEnumID[e]
|
||||||
|
if !ok {
|
||||||
|
return nil, fmt.Errorf("Invalid EnumType[%s] value", e)
|
||||||
|
}
|
||||||
|
return json.Marshal(value)
|
||||||
|
}
|
||||||
|
|
||||||
|
func (e MetricStatusEnum) UnmarshalJSON(b []byte) error {
|
||||||
|
var s string
|
||||||
|
err := json.Unmarshal(b, &s)
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
|
||||||
|
value, ok := metricStatusEnumKey[s]
|
||||||
|
if !ok {
|
||||||
|
return fmt.Errorf("Invalid EnumType[%s] value", s)
|
||||||
|
}
|
||||||
|
e = value
|
||||||
|
return nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user