aboutsummaryrefslogtreecommitdiff
path: root/plugin/file/zone.go
diff options
context:
space:
mode:
authorGravatar marqc <marqc@users.noreply.github.com> 2018-09-29 17:50:49 +0200
committerGravatar Miek Gieben <miek@miek.nl> 2018-09-29 16:50:49 +0100
commit552aab723c05088d049f085ee3b480dac1dbdba7 (patch)
treecd6ecf70b028a1b4412728b967be9d1abd26678c /plugin/file/zone.go
parenta80ec6096f71337600ff2694040be1efb7b6b87b (diff)
downloadcoredns-552aab723c05088d049f085ee3b480dac1dbdba7.tar.gz
coredns-552aab723c05088d049f085ee3b480dac1dbdba7.tar.zst
coredns-552aab723c05088d049f085ee3b480dac1dbdba7.zip
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
Diffstat (limited to 'plugin/file/zone.go')
-rw-r--r--plugin/file/zone.go7
1 files changed, 5 insertions, 2 deletions
diff --git a/plugin/file/zone.go b/plugin/file/zone.go
index 5aa72175f..ecfd74faa 100644
--- a/plugin/file/zone.go
+++ b/plugin/file/zone.go
@@ -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()
}