diff --git a/README.md b/README.md index 2189f50..ecdd76e 100644 --- a/README.md +++ b/README.md @@ -23,9 +23,9 @@ If monitoring is enabled (via the *prometheus* directive) the following metric i The `server` label indicated which server handled the request, see the *metrics* plugin for details. -## Health +## Ready -This plugin implements dynamic health checking. It will always return healthy though. +This plugin reports readiness to the ready plugin. It will be immediately ready. ## Examples diff --git a/example.go b/example.go index 94a271b..9ccaad4 100644 --- a/example.go +++ b/example.go @@ -4,6 +4,7 @@ package example import ( + "context" "fmt" "io" "os" @@ -13,7 +14,6 @@ import ( clog "github.com/coredns/coredns/plugin/pkg/log" "github.com/miekg/dns" - "golang.org/x/net/context" ) // Define log to be a logger with the plugin name in it. This way we can just use log.Info and diff --git a/example_test.go b/example_test.go index 93aade5..6b98814 100644 --- a/example_test.go +++ b/example_test.go @@ -2,13 +2,13 @@ package example import ( "bytes" + "context" "testing" "github.com/coredns/coredns/plugin/pkg/dnstest" "github.com/coredns/coredns/plugin/test" "github.com/miekg/dns" - "golang.org/x/net/context" ) func TestExample(t *testing.T) { diff --git a/go.mod b/go.mod index 50383a7..dd06099 100644 --- a/go.mod +++ b/go.mod @@ -1,10 +1,10 @@ module github.com/coredns/example -go 1.12 +go 1.13 require ( github.com/caddyserver/caddy v1.0.1 - github.com/coredns/coredns v1.5.2 + github.com/coredns/coredns v1.6.3 github.com/miekg/dns v1.1.15 github.com/prometheus/client_golang v1.0.0 golang.org/x/net v0.0.0-20190628185345-da137c7871d7 diff --git a/health.go b/health.go deleted file mode 100644 index b8a503b..0000000 --- a/health.go +++ /dev/null @@ -1,14 +0,0 @@ -package example - -// Health implements the health.Healther interface. -func (e Example) Health() bool { - // More advanced plugins will check their state, i.e. are they - // synchronized correctly against their backend etc. - - // Be careful though by making this a single point of failure. I.e. if 5 CoreDNS - // instances are talking to the same backend and the backend goes down, *all* your - // instances are unhealthy. - - // This one just returns OK. - return true -} diff --git a/ready.go b/ready.go new file mode 100644 index 0000000..8175a9a --- /dev/null +++ b/ready.go @@ -0,0 +1,5 @@ +package example + +// Ready implements the ready.Readiness interface, once this flips to true CoreDNS +// assumes this plugin is ready for queries; it is not checked again. +func (e Example) Ready() bool { return true } diff --git a/setup.go b/setup.go index 19ee5f0..20c8fd9 100644 --- a/setup.go +++ b/setup.go @@ -8,14 +8,8 @@ import ( "github.com/caddyserver/caddy" ) -// init registers this plugin within the Caddy plugin framework. It uses "example" as the -// name, and couples it to the Action "setup". -func init() { - caddy.RegisterPlugin("example", caddy.Plugin{ - ServerType: "dns", - Action: setup, - }) -} +// init registers this plugin. +func init() { plugin.Register("example", setup) } // setup is the function that gets called when the config parser see the token "example". Setup is responsible // for parsing any extra options the example plugin may have. The first token this function sees is "example".