Documentation ¶
Index ¶
- Constants
- func GetAllPluginTag() []string
- func GetConfigurablePluginTypes() []string
- func InitAndRegPlugin(c *Config) (err error)
- func MustRegPlugin(p Plugin)
- func NewErrFromTemplate(t ErrTemplate, args ...interface{}) error
- func PluginFatalErr(tag string, msg string)
- func PurgePluginRegister()
- func RegInitFunc(pluginType string, initFunc NewPluginFunc)
- func RegPlugin(p Plugin) error
- func Walk(ctx context.Context, qCtx *Context, entry string) (err error)
- func WeakDecode(in map[string]interface{}, output interface{}) error
- type Config
- type Context
- type DefaultServerHandler
- type DummyFunctional
- type DummyMatcher
- type DummyRouterPlugin
- type DummyServerHandler
- type ErrTemplate
- type Error
- type Functional
- type FunctionalPlugin
- type FunctionalPluginWrapper
- type Matcher
- type MatcherPlugin
- type MatcherPluginWrapper
- type NewPluginFunc
- type Plugin
- type ResponseWriter
- type RouterPlugin
- type ServerHandler
Constants ¶
const ( ETInvalidArgs = "invalid args: %w" ETPluginErr = "plugin %s reported an err: %w" ETTypeNotDefined = "plugin type %s not defined" ETTagNotDefined = "plugin tag %s not defined" )
const (
// IterationLimit is to prevent endless loops.
IterationLimit = 50
)
Variables ¶
This section is empty.
Functions ¶
func GetAllPluginTag ¶ added in v0.15.0
func GetAllPluginTag() []string
func GetConfigurablePluginTypes ¶ added in v0.15.0
func GetConfigurablePluginTypes() []string
GetConfigurablePluginTypes returns all plugin types which are configurable.
func InitAndRegPlugin ¶ added in v0.10.0
InitAndRegPlugin inits and registers this plugin globally. Duplicate plugin tags are not allowed.
func MustRegPlugin ¶ added in v0.14.0
func MustRegPlugin(p Plugin)
MustRegPlugin: see RegPlugin. MustRegPlugin will panic if err.
func NewErrFromTemplate ¶ added in v0.12.0
func NewErrFromTemplate(t ErrTemplate, args ...interface{}) error
func PluginFatalErr ¶ added in v0.16.0
PluginFatalErr: If a plugin has a fatal err, call this.
func PurgePluginRegister ¶ added in v0.12.0
func PurgePluginRegister()
PurgePluginRegister should only be used in test.
func RegInitFunc ¶
func RegInitFunc(pluginType string, initFunc NewPluginFunc)
RegInitFunc registers this plugin type. This should only be called in init() of the plugin package. Duplicate plugin types are not allowed.
func RegPlugin ¶
RegPlugin registers this Plugin globally. Duplicate Plugin tag will cause an error.
func Walk ¶
Walk walks into RouterPlugin. entry must be an RouterPlugin tag. Walk will stop and return when last RouterPlugin.Do() returns: 1. An empty tag. 2. An error.
func WeakDecode ¶ added in v0.13.0
WeakDecode decodes args from config to output.
Types ¶
type DefaultServerHandler ¶ added in v0.15.0
DefaultServerHandler If entry returns an err, a SERVFAIL response will be sent back to client.
func (*DefaultServerHandler) ServeDNS ¶ added in v0.15.0
func (h *DefaultServerHandler) ServeDNS(ctx context.Context, qCtx *Context, w ResponseWriter)
ServeDNS: see DefaultServerHandler.
type DummyFunctional ¶ added in v0.10.0
type DummyFunctional struct {
WantErr error
}
type DummyMatcher ¶ added in v0.10.0
type DummyRouterPlugin ¶ added in v0.12.0
func (*DummyRouterPlugin) Tag ¶ added in v0.12.0
func (d *DummyRouterPlugin) Tag() string
func (*DummyRouterPlugin) Type ¶ added in v0.12.0
func (d *DummyRouterPlugin) Type() string
type DummyServerHandler ¶ added in v0.16.0
func (*DummyServerHandler) ServeDNS ¶ added in v0.16.0
func (d *DummyServerHandler) ServeDNS(_ context.Context, qCtx *Context, w ResponseWriter)
type ErrTemplate ¶ added in v0.12.0
type ErrTemplate string
type Functional ¶ added in v0.10.0
type FunctionalPlugin ¶ added in v0.10.0
type FunctionalPlugin interface { Plugin Functional }
func GetFunctionalPlugin ¶ added in v0.10.0
func GetFunctionalPlugin(tag string) (p FunctionalPlugin, err error)
type FunctionalPluginWrapper ¶ added in v0.10.0
type FunctionalPluginWrapper struct { Functional // contains filtered or unexported fields }
func WrapFunctionalPlugin ¶ added in v0.10.0
func WrapFunctionalPlugin(tag, typ string, functional Functional) *FunctionalPluginWrapper
WrapFunctionalPlugin returns a *FunctionalPluginWrapper which implements Plugin and FunctionalPlugin.
func (*FunctionalPluginWrapper) Tag ¶ added in v0.10.0
func (p *FunctionalPluginWrapper) Tag() string
func (*FunctionalPluginWrapper) Type ¶ added in v0.10.0
func (p *FunctionalPluginWrapper) Type() string
type MatcherPlugin ¶ added in v0.10.0
func GetMatcherPlugin ¶ added in v0.10.0
func GetMatcherPlugin(tag string) (p MatcherPlugin, err error)
type MatcherPluginWrapper ¶ added in v0.10.0
type MatcherPluginWrapper struct { Matcher // contains filtered or unexported fields }
func WrapMatcherPlugin ¶ added in v0.10.0
func WrapMatcherPlugin(tag, typ string, matcher Matcher) *MatcherPluginWrapper
WrapMatcherPlugin returns a *MatcherPluginWrapper which implements Plugin and MatcherPlugin.
func (*MatcherPluginWrapper) Tag ¶ added in v0.10.0
func (c *MatcherPluginWrapper) Tag() string
func (*MatcherPluginWrapper) Type ¶ added in v0.10.0
func (c *MatcherPluginWrapper) Type() string
type NewPluginFunc ¶
type ResponseWriter ¶ added in v0.15.0
ResponseWriter can write msg to the client.
type RouterPlugin ¶ added in v0.10.0
type RouterPlugin interface { Plugin Do(ctx context.Context, qCtx *Context) (next string, err error) }
func GetRouterPlugin ¶ added in v0.10.0
func GetRouterPlugin(tag string) (p RouterPlugin, err error)
type ServerHandler ¶ added in v0.15.0
type ServerHandler interface { // ServeDNS use ctx to control deadline, exchange qCtx, and write response to w. ServeDNS(ctx context.Context, qCtx *Context, w ResponseWriter) }