mirror of
https://github.com/coredns/coredns.git
synced 2025-11-01 10:43:17 -04:00
map bool -> map struct{} (#2386)
This clear out the remaining map[x]bool usage and moves the bool to an empty struct. Two note worthy other changes: * EnableChaos in the server is now also exported to make it show up in the documentation. * The auto plugin is left as is, because there the boolean is explicitaly set to false to signal 'to-be-deleted' and the key is left as-is. Signed-off-by: Miek Gieben <miek@miek.nl>
This commit is contained in:
@@ -26,7 +26,7 @@ type Metrics struct {
|
||||
srv *http.Server
|
||||
|
||||
zoneNames []string
|
||||
zoneMap map[string]bool
|
||||
zoneMap map[string]struct{}
|
||||
zoneMu sync.RWMutex
|
||||
}
|
||||
|
||||
@@ -35,7 +35,7 @@ func New(addr string) *Metrics {
|
||||
met := &Metrics{
|
||||
Addr: addr,
|
||||
Reg: prometheus.NewRegistry(),
|
||||
zoneMap: make(map[string]bool),
|
||||
zoneMap: make(map[string]struct{}),
|
||||
}
|
||||
// Add the default collectors
|
||||
met.MustRegister(prometheus.NewGoCollector())
|
||||
@@ -69,7 +69,7 @@ func (m *Metrics) MustRegister(c prometheus.Collector) {
|
||||
// AddZone adds zone z to m.
|
||||
func (m *Metrics) AddZone(z string) {
|
||||
m.zoneMu.Lock()
|
||||
m.zoneMap[z] = true
|
||||
m.zoneMap[z] = struct{}{}
|
||||
m.zoneNames = keys(m.zoneMap)
|
||||
m.zoneMu.Unlock()
|
||||
}
|
||||
@@ -140,7 +140,7 @@ func (m *Metrics) OnFinalShutdown() error {
|
||||
return m.stopServer()
|
||||
}
|
||||
|
||||
func keys(m map[string]bool) []string {
|
||||
func keys(m map[string]struct{}) []string {
|
||||
sx := []string{}
|
||||
for k := range m {
|
||||
sx = append(sx, k)
|
||||
|
||||
Reference in New Issue
Block a user