mirror of
https://github.com/coredns/coredns.git
synced 2025-10-27 16:24:19 -04:00
Configurable zone reload interval in file plugin (#2110)
* Configurable zone reload interval in file plugin * passing reload config from auto plugin to file plugin. removed noReload property from Zone struct. fixed tests based on short file reload hack
This commit is contained in:
@@ -6,6 +6,7 @@ import (
|
||||
"path"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
"github.com/coredns/coredns/plugin/file/tree"
|
||||
"github.com/coredns/coredns/plugin/pkg/upstream"
|
||||
@@ -27,7 +28,8 @@ type Zone struct {
|
||||
TransferFrom []string
|
||||
Expired *bool
|
||||
|
||||
NoReload bool
|
||||
ReloadInterval time.Duration
|
||||
LastReloaded time.Time
|
||||
reloadMu sync.RWMutex
|
||||
reloadShutdown chan bool
|
||||
Upstream upstream.Upstream // Upstream for looking up names during the resolution process
|
||||
@@ -50,6 +52,7 @@ func NewZone(name, file string) *Zone {
|
||||
Tree: &tree.Tree{},
|
||||
Expired: new(bool),
|
||||
reloadShutdown: make(chan bool),
|
||||
LastReloaded: time.Now(),
|
||||
}
|
||||
*z.Expired = false
|
||||
|
||||
@@ -161,7 +164,7 @@ func (z *Zone) TransferAllowed(state request.Request) bool {
|
||||
// All returns all records from the zone, the first record will be the SOA record,
|
||||
// otionally followed by all RRSIG(SOA)s.
|
||||
func (z *Zone) All() []dns.RR {
|
||||
if !z.NoReload {
|
||||
if z.ReloadInterval > 0 {
|
||||
z.reloadMu.RLock()
|
||||
defer z.reloadMu.RUnlock()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user