1 Star 0 Fork 0

zhangjungang/beats

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
registry.go 1.01 KB
一键复制 编辑 原始数据 按行查看 历史
package processors
import (
"errors"
"github.com/elastic/beats/libbeat/common"
"github.com/elastic/beats/libbeat/logp"
p "github.com/elastic/beats/libbeat/plugin"
)
type processorPlugin struct {
name string
constr Constructor
}
var pluginKey = "libbeat.processor"
func Plugin(name string, c Constructor) map[string][]interface{} {
return p.MakePlugin(pluginKey, processorPlugin{name, c})
}
func init() {
p.MustRegisterLoader(pluginKey, func(ifc interface{}) error {
p, ok := ifc.(processorPlugin)
if !ok {
return errors.New("plugin does not match processor plugin type")
}
return registry.Register(p.name, p.constr)
})
}
type Processor interface {
Run(event common.MapStr) (common.MapStr, error)
String() string
}
type Constructor func(config common.Config) (Processor, error)
var registry = NewNamespace()
func RegisterPlugin(name string, constructor Constructor) {
logp.Debug("processors", "Register plugin %s", name)
err := registry.Register(name, constructor)
if err != nil {
panic(err)
}
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/zhangjungang/beats.git
git@gitee.com:zhangjungang/beats.git
zhangjungang
beats
beats
v5.4.1

搜索帮助

0d507c66 1850385 C8b1a773 1850385