Преглед изворни кода

plugin/example: add health

Fixes #4
Miek Gieben пре 7 година
родитељ
комит
307c280e10
2 измењених фајлова са 18 додато и 0 уклоњено
  1. 4 0
      README.md
  2. 14 0
      health.go

+ 4 - 0
README.md

@@ -23,6 +23,10 @@ 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.
 The `server` label indicated which server handled the request, see the *metrics* plugin for details.
 
 
+## Health
+
+This plugin implements dynamic health checking. It will also return healthy though.
+
 ## Examples
 ## Examples
 
 
 In this configuration, we forward all queries to 9.9.9.9 and print "example" whenever we receive
 In this configuration, we forward all queries to 9.9.9.9 and print "example" whenever we receive

+ 14 - 0
health.go

@@ -0,0 +1,14 @@
+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
+}