1
0
mirror of https://github.com/StackExchange/dnscontrol.git synced 2024-05-11 05:55:12 +00:00

NEW FEATURE: Gather data for providers concurrently (#2873)

This commit is contained in:
Tom Limoncelli
2024-03-27 13:54:36 -04:00
committed by GitHub
parent 408a70ec76
commit 68c5e87c89
17 changed files with 933 additions and 67 deletions

27
commands/zonecache.go Normal file
View File

@ -0,0 +1,27 @@
package commands
import "github.com/StackExchange/dnscontrol/v4/providers"
func NewZoneCache() *zoneCache {
return &zoneCache{}
}
func (zc *zoneCache) zoneList(name string, lister providers.ZoneLister) (*[]string, error) {
zc.Lock()
defer zc.Unlock()
if zc.cache == nil {
zc.cache = map[string]*[]string{}
}
if v, ok := zc.cache[name]; ok {
return v, nil
}
zones, err := lister.ListZones()
if err != nil {
return nil, err
}
zc.cache[name] = &zones
return &zones, nil
}