1 Star 0 Fork 0

sqos/beats

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
forwarder.go 1.02 KB
一键复制 编辑 原始数据 按行查看 历史
package harvester
import (
"errors"
"github.com/elastic/beats/filebeat/util"
"github.com/elastic/beats/libbeat/logp"
)
// Outlet interface is used for forwarding events
type Outlet interface {
OnEvent(data *util.Data) bool
}
// Forwarder contains shared options between all harvesters needed to forward events
type Forwarder struct {
Outlet Outlet
}
// ForwarderConfig contains all config options shared by all harvesters
type ForwarderConfig struct {
Type string `config:"type"`
}
// NewForwarder creates a new forwarder instances and initialises processors if configured
func NewForwarder(outlet Outlet) *Forwarder {
return &Forwarder{Outlet: outlet}
}
// Send updates the prospector state and sends the event to the spooler
// All state updates done by the prospector itself are synchronous to make sure no states are overwritten
func (f *Forwarder) Send(data *util.Data) error {
ok := f.Outlet.OnEvent(data)
if !ok {
logp.Info("Prospector outlet closed")
return errors.New("prospector outlet closed")
}
return nil
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/sqos/beats.git
git@gitee.com:sqos/beats.git
sqos
beats
beats
v6.2.4

搜索帮助