aboutsummaryrefslogtreecommitdiff
path: root/plugin/erratic/ready.go
diff options
context:
space:
mode:
Diffstat (limited to 'plugin/erratic/ready.go')
-rw-r--r--plugin/erratic/ready.go13
1 files changed, 13 insertions, 0 deletions
diff --git a/plugin/erratic/ready.go b/plugin/erratic/ready.go
new file mode 100644
index 000000000..d5f18a6d5
--- /dev/null
+++ b/plugin/erratic/ready.go
@@ -0,0 +1,13 @@
+package erratic
+
+import "sync/atomic"
+
+// Ready returns true if the number of received queries is in the range [3, 5). All other values return false.
+// To aid in testing we want to this flip between ready and not ready.
+func (e *Erratic) Ready() bool {
+ q := atomic.LoadUint64(&e.q)
+ if q >= 3 && q < 5 {
+ return true
+ }
+ return false
+}