2021-12-27 15:02:41 +03:00
|
|
|
package app
|
2021-12-27 15:11:48 +03:00
|
|
|
|
2021-12-27 21:15:02 +03:00
|
|
|
import (
|
|
|
|
"flag"
|
|
|
|
"fmt"
|
|
|
|
"log"
|
|
|
|
"net/http"
|
|
|
|
|
|
|
|
"github.com/caarlos0/env"
|
|
|
|
rclient "github.com/khorevaa/ras-client"
|
|
|
|
"github.com/prometheus/client_golang/prometheus"
|
|
|
|
"github.com/prometheus/client_golang/prometheus/promhttp"
|
|
|
|
)
|
|
|
|
|
|
|
|
var (
|
|
|
|
conf Config
|
|
|
|
hostFlag string
|
|
|
|
portFlag string
|
|
|
|
)
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
if err := env.Parse(&conf); err != nil {
|
|
|
|
log.Fatalf("app: config...")
|
|
|
|
}
|
|
|
|
|
|
|
|
flag.StringVar(&hostFlag, "host", "", "cluster host.")
|
|
|
|
flag.StringVar(&portFlag, "port", "", "cluster port.")
|
|
|
|
flag.Parse()
|
|
|
|
|
|
|
|
if hostFlag != "" {
|
|
|
|
conf.Host = hostFlag
|
|
|
|
}
|
|
|
|
|
|
|
|
if portFlag != "" {
|
|
|
|
conf.Port = portFlag
|
|
|
|
}
|
|
|
|
}
|
2021-12-27 15:11:48 +03:00
|
|
|
|
|
|
|
func Run() error {
|
2021-12-27 21:15:02 +03:00
|
|
|
|
|
|
|
_ = rclient.NewClient(fmt.Sprintf("%s:%s", conf.Host, conf.Port))
|
|
|
|
|
|
|
|
promRegistry := prometheus.NewRegistry()
|
|
|
|
promRegistry.MustRegister()
|
2021-12-27 22:48:08 +03:00
|
|
|
_ = prometheus.NewGauge(
|
|
|
|
prometheus.GaugeOpts{
|
|
|
|
Namespace: "",
|
|
|
|
Subsystem: "",
|
|
|
|
Name: "",
|
|
|
|
Help: "",
|
|
|
|
ConstLabels: map[string]string{},
|
|
|
|
})
|
|
|
|
|
|
|
|
_ = prometheus.NewCounterVec(
|
|
|
|
prometheus.CounterOpts{
|
|
|
|
Namespace: "",
|
|
|
|
Subsystem: "",
|
|
|
|
Name: "",
|
|
|
|
Help: "",
|
|
|
|
ConstLabels: map[string]string{},
|
|
|
|
},
|
|
|
|
nil,
|
|
|
|
)
|
|
|
|
|
2021-12-27 21:15:02 +03:00
|
|
|
http.Handle("/metrics", promhttp.HandlerFor(promRegistry, promhttp.HandlerOpts{}))
|
|
|
|
|
2021-12-27 15:11:48 +03:00
|
|
|
return fmt.Errorf("app: not implemented")
|
2021-12-27 21:15:02 +03:00
|
|
|
|
2021-12-27 15:11:48 +03:00
|
|
|
}
|