1 Star 0 Fork 0

sqos/beats

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
publish.go 961 Bytes
一键复制 编辑 原始数据 按行查看 历史
package module
import (
"sync"
"github.com/elastic/beats/libbeat/beat"
)
// PublishChannels publishes the events read from each channel to the given
// publisher client. If the publisher client blocks for any reason then events
// will not be read from the given channels.
//
// This method blocks until all of the channels have been closed
// and are fully read. To stop the method immediately, close the channels and
// close the publisher client to ensure that publishing does not block. This
// may result is some events being discarded.
func PublishChannels(client beat.Client, cs ...<-chan beat.Event) {
var wg sync.WaitGroup
// output publishes values from c until c is closed, then calls wg.Done.
output := func(c <-chan beat.Event) {
defer wg.Done()
for event := range c {
client.Publish(event)
}
}
// Start an output goroutine for each input channel in cs.
wg.Add(len(cs))
for _, c := range cs {
go output(c)
}
wg.Wait()
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/sqos/beats.git
git@gitee.com:sqos/beats.git
sqos
beats
beats
v6.2.0

搜索帮助

0d507c66 1850385 C8b1a773 1850385