1 Star 0 Fork 0

zhangjungang/beats

Create your Gitee Account
Explore and code with more than 12 million developers,Free private repositories !:)
Sign up
文件
Clone or Download
registry.go 1.38 KB
Copy Edit Raw Blame History
package add_kubernetes_metadata
import (
"errors"
"fmt"
p "github.com/elastic/beats/libbeat/plugin"
)
var (
indexerKey = "libbeat.processor.kubernetes.indexer"
matcherKey = "libbeat.processor.kubernetes.matcher"
)
type indexerPlugin struct {
name string
constructor IndexerConstructor
}
func IndexerPlugin(name string, c IndexerConstructor) map[string][]interface{} {
return p.MakePlugin(indexerKey, indexerPlugin{name, c})
}
type matcherPlugin struct {
name string
constructor MatcherConstructor
}
func MatcherPlugin(name string, m MatcherConstructor) map[string][]interface{} {
return p.MakePlugin(matcherKey, matcherPlugin{name, m})
}
func init() {
p.MustRegisterLoader(indexerKey, func(ifc interface{}) error {
i, ok := ifc.(indexerPlugin)
if !ok {
return errors.New("plugin does not match output plugin type")
}
name := i.name
if Indexing.indexers[name] != nil {
return fmt.Errorf("indexer type %v already registered", name)
}
Indexing.AddIndexer(name, i.constructor)
return nil
})
p.MustRegisterLoader(matcherKey, func(ifc interface{}) error {
m, ok := ifc.(matcherPlugin)
if !ok {
return errors.New("plugin does not match output plugin type")
}
name := m.name
if Indexing.indexers[name] != nil {
return fmt.Errorf("matcher type %v already registered", name)
}
Indexing.AddMatcher(name, m.constructor)
return nil
})
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/zhangjungang/beats.git
git@gitee.com:zhangjungang/beats.git
zhangjungang
beats
beats
v6.0.0-beta2

Search