* add ready, remove health * use plugin.Register Signed-off-by: Miek Gieben <miek@miek.nl>
@@ -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
@@ -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
@@ -2,13 +2,13 @@ package example
"bytes"
"testing"
"github.com/coredns/coredns/plugin/pkg/dnstest"
"github.com/coredns/coredns/plugin/test"
func TestExample(t *testing.T) {
@@ -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
@@ -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
-}
@@ -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 }
@@ -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".