diff options
author | 2020-02-04 07:59:08 -0500 | |
---|---|---|
committer | 2020-02-04 13:59:08 +0100 | |
commit | 22cd28a7987afc24161b110b550d3e62347d1626 (patch) | |
tree | 13431983c1374533989d34f9af2a4d981786a316 /plugin/forward/setup.go | |
parent | 8724a134c47b2d86fc20935201a4a8095ff290c4 (diff) | |
download | coredns-22cd28a7987afc24161b110b550d3e62347d1626.tar.gz coredns-22cd28a7987afc24161b110b550d3e62347d1626.tar.zst coredns-22cd28a7987afc24161b110b550d3e62347d1626.zip |
plugins/forward: Add max_concurrent option (#3640)
* count and limit concurrent queries
Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
* add option
Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
* return servfail when limit exceeded
Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
* docs
Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
* docs
Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
* docs
Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
* review feedback
Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
* move atomic counter to beginning of struct
Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
* add comment for ErrLimitExceeded
Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
* rename option to max_concurrent
Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
* add metric
Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
* response REFUSED; incl max in error; add more docs
Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
* avoid err setup race
Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
* respond SERVFAIL; doc memory usage
Signed-off-by: Chris O'Haver <cohaver@infoblox.com>
Diffstat (limited to 'plugin/forward/setup.go')
-rw-r--r-- | plugin/forward/setup.go | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/plugin/forward/setup.go b/plugin/forward/setup.go index fa35639f2..dadf535c7 100644 --- a/plugin/forward/setup.go +++ b/plugin/forward/setup.go @@ -1,6 +1,7 @@ package forward import ( + "errors" "fmt" "strconv" "time" @@ -121,6 +122,7 @@ func parseStanza(c *caddy.Controller) (*Forward, error) { } f.proxies[i].SetExpire(f.expire) } + return f, nil } @@ -211,6 +213,19 @@ func parseBlock(c *caddy.Controller, f *Forward) error { default: return c.Errf("unknown policy '%s'", x) } + case "max_concurrent": + if !c.NextArg() { + return c.ArgErr() + } + n, err := strconv.Atoi(c.Val()) + if err != nil { + return err + } + if n < 0 { + return fmt.Errorf("max_concurrent can't be negative: %d", n) + } + f.ErrLimitExceeded = errors.New("concurrent queries exceeded maximum " + c.Val()) + f.maxConcurrent = int64(n) default: return c.Errf("unknown property '%s'", c.Val()) |