aboutsummaryrefslogtreecommitdiff
path: root/plugin/cancel/README.md
blob: 64f585a294695f8b8cd2cdd9dfd5f440a460c897 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
# cancel

## Name

*cancel* - cancels a request's context after 5001 milliseconds.

## Description

The *cancel* plugin creates a canceling context for each request. It adds a timeout that gets
triggered after 5001 milliseconds.

The 5001 number was chosen because the default timeout for DNS clients is 5 seconds, after that they
give up.

A plugin interested in the cancellation status should call `plugin.Done()` on the context. If the
context was canceled due to a timeout the plugin should not write anything back to the client and
return a value indicating CoreDNS should not either; a zero return value should suffice for that.

## Syntax

~~~ txt
cancel [TIMEOUT]
~~~

* **TIMEOUT** allows setting a custom timeout. The default timeout is 5001 milliseconds (`5001 ms`)

## Examples

~~~ corefile
example.org {
    cancel
    whoami
}
~~~

Or with a custom timeout:

~~~ corefile
example.org {
    cancel 1s
    whoami
}
~~~

## See Also

The Go documentation for the context package.