Documentation
¶
Index ¶
- func AddSubCmd(c *cobra.Command)
- func DelPluginType(typ string)
- func GetAllPluginTypes() []string
- func LoadNewPersetPluginFuncs() map[string]NewPersetPluginFunc
- func RegNewPersetPluginFunc(tag string, f NewPersetPluginFunc)
- func RegNewPluginFunc(typ string, initFunc NewPluginFunc, argsType NewPluginArgsFunc)
- func Run() error
- type APIConfig
- type BP
- type Config
- type Mosdns
- func (m *Mosdns) CloseWithErr(err error)
- func (m *Mosdns) GetAPIRouter() *chi.Mux
- func (m *Mosdns) GetMetricsReg() prometheus.Registerer
- func (m *Mosdns) GetPlugin(tag string) any
- func (m *Mosdns) GetSafeClose() *safe_close.SafeClose
- func (m *Mosdns) Logger() *zap.Logger
- func (m *Mosdns) RegPluginAPI(tag string, mux *chi.Mux)
- type NewPersetPluginFunc
- type NewPluginArgsFunc
- type NewPluginFunc
- type PluginConfig
- type PluginTypeInfo
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DelPluginType ¶
func DelPluginType(typ string)
DelPluginType deletes the init func for this plugin type. It is a noop if pluginType is not registered.
func GetAllPluginTypes ¶
func GetAllPluginTypes() []string
GetAllPluginTypes returns all plugin types which are configurable.
func LoadNewPersetPluginFuncs ¶
func LoadNewPersetPluginFuncs() map[string]NewPersetPluginFunc
func RegNewPersetPluginFunc ¶
func RegNewPersetPluginFunc(tag string, f NewPersetPluginFunc)
func RegNewPluginFunc ¶
func RegNewPluginFunc(typ string, initFunc NewPluginFunc, argsType NewPluginArgsFunc)
RegNewPluginFunc registers the type. If the type has been registered. RegNewPluginFunc will panic.
Types ¶
type BP ¶
type BP struct {
// contains filtered or unexported fields
}
type Config ¶
type Config struct {
Log mlog.LogConfig `yaml:"log"`
Include []string `yaml:"include"`
Plugins []PluginConfig `yaml:"plugins"`
API APIConfig `yaml:"api"`
}
type Mosdns ¶
type Mosdns struct {
// contains filtered or unexported fields
}
func NewTestMosdnsWithPlugins ¶
NewTestMosdnsWithPlugins returns a mosdns instance for testing.
func (*Mosdns) CloseWithErr ¶
CloseWithErr is a shortcut for m.sc.SendCloseSignal
func (*Mosdns) GetAPIRouter ¶
func (*Mosdns) GetMetricsReg ¶
func (m *Mosdns) GetMetricsReg() prometheus.Registerer
GetMetricsReg returns a prometheus.Registerer with a prefix of "mosdns_"
func (*Mosdns) GetSafeClose ¶
func (m *Mosdns) GetSafeClose() *safe_close.SafeClose
type NewPersetPluginFunc ¶
type NewPluginArgsFunc ¶
type NewPluginArgsFunc func() any
NewPluginArgsFunc represents a func that creates a new args object.
type NewPluginFunc ¶
NewPluginFunc represents a func that can init a Plugin. args is the object created by NewPluginArgsFunc.
type PluginConfig ¶
type PluginConfig struct {
// Tag for this plugin. Optional. If omitted, this plugin will
// be registered with a random tag.
Tag string `yaml:"tag"`
// Type, required.
Type string `yaml:"type"`
// Args, might be required by some plugins.
// The type of Args is depended on RegNewPluginFunc.
// If it's a map[string]any, it will be converted by mapstruct.
Args any `yaml:"args"`
}
PluginConfig represents a plugin config
type PluginTypeInfo ¶
type PluginTypeInfo struct {
NewPlugin NewPluginFunc
NewArgs NewPluginArgsFunc
}
func GetPluginType ¶
func GetPluginType(typ string) (PluginTypeInfo, bool)
GetPluginType gets the registered type init func.