1 Star 0 Fork 0

sqos/beats

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
publisher.go 1.46 KB
一键复制 编辑 原始数据 按行查看 历史
package publisher
import (
"errors"
"expvar"
"github.com/elastic/beats/filebeat/input"
"github.com/elastic/beats/libbeat/common"
"github.com/elastic/beats/libbeat/logp"
"github.com/elastic/beats/libbeat/publisher"
)
var (
eventsSent = expvar.NewInt("publish.events")
)
// LogPublisher provides functionality to start and stop a publisher worker.
type LogPublisher interface {
Start()
Stop()
}
// SuccessLogger is used to report successfully published events.
type SuccessLogger interface {
// Published will be run after events have been acknowledged by the outputs.
Published(events []*input.Event) bool
}
func New(
async bool,
in chan []*input.Event,
out SuccessLogger,
pub publisher.Publisher,
) LogPublisher {
if async {
logp.Warn("publish_async is experimental and will be removed in a future version!")
return newAsyncLogPublisher(in, out, pub)
}
return newSyncLogPublisher(in, out, pub)
}
var (
sigPublisherStop = errors.New("publisher was stopped")
)
// getDataEvents returns all events which contain data (not only state updates)
// together with their associated metadata
func getDataEvents(events []*input.Event) (dataEvents []common.MapStr, meta []common.MapStr) {
dataEvents = make([]common.MapStr, 0, len(events))
meta = make([]common.MapStr, 0, len(events))
for _, event := range events {
if event.HasData() {
dataEvents = append(dataEvents, event.ToMapStr())
meta = append(meta, event.Metadata())
}
}
return dataEvents, meta
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/sqos/beats.git
git@gitee.com:sqos/beats.git
sqos
beats
beats
v5.6.7

搜索帮助

0d507c66 1850385 C8b1a773 1850385