diff options
author | 2018-04-25 11:45:09 +0100 | |
---|---|---|
committer | 2018-04-25 11:45:09 +0100 | |
commit | 5e6114b797b56d4b0f910d0c11a5dc85b37bfd52 (patch) | |
tree | dd489f9c9918d0dbad6719411d19b133bb5040a6 /plugin/metrics/setup.go | |
parent | ce084012df435a98cac5511a294a0c45a1a3abf9 (diff) | |
download | coredns-5e6114b797b56d4b0f910d0c11a5dc85b37bfd52.tar.gz coredns-5e6114b797b56d4b0f910d0c11a5dc85b37bfd52.tar.zst coredns-5e6114b797b56d4b0f910d0c11a5dc85b37bfd52.zip |
plugin/pkg/uniq: add (#1733)
Spin this out the metrics package so we can use it in the health
one of well to fix some reload bugs.
Diffstat (limited to 'plugin/metrics/setup.go')
-rw-r--r-- | plugin/metrics/setup.go | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/plugin/metrics/setup.go b/plugin/metrics/setup.go index 52d5775c1..c00f44a83 100644 --- a/plugin/metrics/setup.go +++ b/plugin/metrics/setup.go @@ -8,19 +8,21 @@ import ( "github.com/coredns/coredns/coremain" "github.com/coredns/coredns/plugin" clog "github.com/coredns/coredns/plugin/pkg/log" + "github.com/coredns/coredns/plugin/pkg/uniq" "github.com/mholt/caddy" ) -var log = clog.NewWithPlugin("prometheus") +var ( + log = clog.NewWithPlugin("prometheus") + uniqAddr = uniq.New() +) func init() { caddy.RegisterPlugin("prometheus", caddy.Plugin{ ServerType: "dns", Action: setup, }) - - uniqAddr = newAddress() } func setup(c *caddy.Controller) error { @@ -36,7 +38,7 @@ func setup(c *caddy.Controller) error { c.OncePerServerBlock(func() error { c.OnStartup(func() error { - return uniqAddr.forEachTodo() + return uniqAddr.ForEach() }) return nil }) @@ -54,7 +56,7 @@ func prometheusParse(c *caddy.Controller) (*Metrics, error) { var met = New(defaultAddr) defer func() { - uniqAddr.setAddress(met.Addr, met.OnStartup) + uniqAddr.Set(met.Addr, met.OnStartup) }() i := 0 |