代码拉取完成,页面将自动刷新
package udp
import (
"github.com/elastic/beats/filebeat/channel"
"github.com/elastic/beats/filebeat/harvester"
"github.com/elastic/beats/filebeat/prospector"
"github.com/elastic/beats/libbeat/common"
"github.com/elastic/beats/libbeat/common/cfgwarn"
"github.com/elastic/beats/libbeat/logp"
)
func init() {
err := prospector.Register("udp", NewProspector)
if err != nil {
panic(err)
}
}
type Prospector struct {
harvester *Harvester
started bool
outlet channel.Outleter
}
func NewProspector(cfg *common.Config, outlet channel.Factory, context prospector.Context) (prospector.Prospectorer, error) {
cfgwarn.Experimental("UDP prospector type is used")
out, err := outlet(cfg, context.DynamicFields)
if err != nil {
return nil, err
}
forwarder := harvester.NewForwarder(out)
return &Prospector{
outlet: out,
harvester: NewHarvester(forwarder, cfg),
started: false,
}, nil
}
func (p *Prospector) Run() {
if !p.started {
logp.Info("Starting udp prospector")
p.started = true
go func() {
defer p.outlet.Close()
err := p.harvester.Run()
if err != nil {
logp.Err("Error running harvester:: %v", err)
}
}()
}
}
func (p *Prospector) Stop() {
logp.Info("Stopping udp prospector")
p.harvester.Stop()
}
func (p *Prospector) Wait() {
p.Stop()
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。