Consolidates the V struct
This commit is contained in:
parent
ce2faa39eb
commit
56bd8445a4
@ -13,11 +13,6 @@ import (
|
|||||||
"mcquay.me/metrics"
|
"mcquay.me/metrics"
|
||||||
)
|
)
|
||||||
|
|
||||||
type v struct {
|
|
||||||
Hostname string `json:"hostname"`
|
|
||||||
V string `json:"version"`
|
|
||||||
}
|
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
m, err := metrics.New("hw")
|
m, err := metrics.New("hw")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@ -29,7 +24,7 @@ func main() {
|
|||||||
}
|
}
|
||||||
http.HandleFunc("/", m.WrapFunc("/", func(w http.ResponseWriter, req *http.Request) {
|
http.HandleFunc("/", m.WrapFunc("/", func(w http.ResponseWriter, req *http.Request) {
|
||||||
w.Header().Set("Content-Type", "application/json")
|
w.Header().Set("Content-Type", "application/json")
|
||||||
r := v{
|
r := hw.V{
|
||||||
Hostname: hn,
|
Hostname: hn,
|
||||||
V: hw.Version,
|
V: hw.Version,
|
||||||
}
|
}
|
||||||
|
@ -17,11 +17,6 @@ import (
|
|||||||
|
|
||||||
var success *prometheus.CounterVec
|
var success *prometheus.CounterVec
|
||||||
|
|
||||||
type v struct {
|
|
||||||
Hostname string `json:"hostname"`
|
|
||||||
V string `json:"version"`
|
|
||||||
}
|
|
||||||
|
|
||||||
type state struct {
|
type state struct {
|
||||||
Hostname string `json:"hostname"`
|
Hostname string `json:"hostname"`
|
||||||
V string `json:"version"`
|
V string `json:"version"`
|
||||||
@ -45,7 +40,7 @@ func (s *state) update(target string) {
|
|||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
success.WithLabelValues("true").Inc()
|
success.WithLabelValues("true").Inc()
|
||||||
rv := v{}
|
rv := hw.V{}
|
||||||
if err := json.NewDecoder(httpResp.Body).Decode(&rv); err != nil {
|
if err := json.NewDecoder(httpResp.Body).Decode(&rv); err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
|
6
hw.go
6
hw.go
@ -6,3 +6,9 @@ var Version = "unset"
|
|||||||
|
|
||||||
// OK simply return 200
|
// OK simply return 200
|
||||||
func OK(w http.ResponseWriter, req *http.Request) {}
|
func OK(w http.ResponseWriter, req *http.Request) {}
|
||||||
|
|
||||||
|
// V houses version information
|
||||||
|
type V struct {
|
||||||
|
Hostname string `json:"hostname"`
|
||||||
|
V string `json:"version"`
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user