代码拉取完成,页面将自动刷新
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()
}
此处可能存在不合适展示的内容,页面不予展示。您可通过相关编辑功能自查并修改。
如您确认内容无涉及 不当用语 / 纯广告导流 / 暴力 / 低俗色情 / 侵权 / 盗版 / 虚假 / 无价值内容或违法国家有关法律法规的内容,可点击提交进行申诉,我们将尽快为您处理。