mirror of
https://github.com/coredns/coredns.git
synced 2025-10-27 08:14:18 -04:00
* Run gostaticheck Run gostaticcheck on the codebase and fix almost all flagged items. Only keep * coremain/run.go:192:2: var appVersion is unused (U1000) * plugin/chaos/setup.go:54:3: the surrounding loop is unconditionally terminated (SA4004) * plugin/etcd/setup.go:103:3: the surrounding loop is unconditionally terminated (SA4004) * plugin/pkg/replacer/replacer.go:274:13: argument should be pointer-like to avoid allocations (SA6002) * plugin/route53/setup.go:124:28: session.New is deprecated: Use NewSession functions to create sessions instead. NewSession has the same functionality as New except an error can be returned when the func is called instead of waiting to receive an error until a request is made. (SA1019) * test/grpc_test.go:25:69: grpc.WithTimeout is deprecated: use DialContext and context.WithTimeout instead. Will be supported throughout 1.x. (SA1019) The first one isn't true, as this is set via ldflags. The rest is minor. The deprecation should be fixed at some point; I'll file some issues. Signed-off-by: Miek Gieben <miek@miek.nl> * Make sure to plug in the plugins import the plugins, that file that did this was removed, put it in the reload test as this requires an almost complete coredns server. Signed-off-by: Miek Gieben <miek@miek.nl>
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.
cancel [TIMEOUT]
- TIMEOUT allows setting a custom timeout. The default timeout is 5001 milliseconds (
5001 ms)
Examples
example.org {
cancel
whoami
}
Or with a custom timeout:
example.org {
cancel 1s
whoami
}
Also See
The Go documentation for the context package.