Consolidates the V struct

This commit is contained in:
Stephen McQuay 2018-03-08 16:15:44 -08:00
parent ce2faa39eb
commit 56bd8445a4
Signed by: sm
GPG Key ID: 4E4B72F479BA3CE5
3 changed files with 8 additions and 12 deletions

View File

@ -13,11 +13,6 @@ import (
"mcquay.me/metrics"
)
type v struct {
Hostname string `json:"hostname"`
V string `json:"version"`
}
func main() {
m, err := metrics.New("hw")
if err != nil {
@ -29,7 +24,7 @@ func main() {
}
http.HandleFunc("/", m.WrapFunc("/", func(w http.ResponseWriter, req *http.Request) {
w.Header().Set("Content-Type", "application/json")
r := v{
r := hw.V{
Hostname: hn,
V: hw.Version,
}

View File

@ -17,11 +17,6 @@ import (
var success *prometheus.CounterVec
type v struct {
Hostname string `json:"hostname"`
V string `json:"version"`
}
type state struct {
Hostname string `json:"hostname"`
V string `json:"version"`
@ -45,7 +40,7 @@ func (s *state) update(target string) {
continue
}
success.WithLabelValues("true").Inc()
rv := v{}
rv := hw.V{}
if err := json.NewDecoder(httpResp.Body).Decode(&rv); err != nil {
panic(err)
}

6
hw.go
View File

@ -6,3 +6,9 @@ var Version = "unset"
// OK simply return 200
func OK(w http.ResponseWriter, req *http.Request) {}
// V houses version information
type V struct {
Hostname string `json:"hostname"`
V string `json:"version"`
}