cancel

package
v1.7.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 24, 2020 License: Apache-2.0 Imports: 7 Imported by: 0

README

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

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.

Documentation

Overview

Package cancel implements a plugin adds a canceling context to each request.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cancel

type Cancel struct {
	Next plugin.Handler
	// contains filtered or unexported fields
}

Cancel is a plugin that adds a canceling context to each request's context.

func (Cancel) Name

func (c Cancel) Name() string

Name implements the Handler interface.

func (Cancel) ServeDNS

func (c Cancel) ServeDNS(ctx context.Context, w dns.ResponseWriter, r *dns.Msg) (int, error)

ServeDNS implements the plugin.Handler interface.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL