1 Star 0 Fork 0

sqos/beats

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
opts.go 1.31 KB
一键复制 编辑 原始数据 按行查看 历史
package publisher
import (
"github.com/elastic/beats/libbeat/common"
"github.com/elastic/beats/libbeat/common/op"
)
// ClientOption allows API users to set additional options when publishing events.
type ClientOption func(option Context) ([]common.MapStr, Context)
// Guaranteed option will retry publishing the event, until send attempt have
// been ACKed by output plugin.
func Guaranteed(o Context) ([]common.MapStr, Context) {
o.Guaranteed = true
return nil, o
}
// Sync option will block the event publisher until an event has been ACKed by
// the output plugin or failed.
func Sync(o Context) ([]common.MapStr, Context) {
o.Sync = true
return nil, o
}
func Signal(signaler op.Signaler) ClientOption {
return func(ctx Context) ([]common.MapStr, Context) {
if ctx.Signal == nil {
ctx.Signal = signaler
} else {
ctx.Signal = op.CombineSignalers(ctx.Signal, signaler)
}
return nil, ctx
}
}
func Metadata(m common.MapStr) ClientOption {
if len(m) == 0 {
return nilOption
}
return func(ctx Context) ([]common.MapStr, Context) {
return []common.MapStr{m}, ctx
}
}
func MetadataBatch(m []common.MapStr) ClientOption {
if len(m) == 0 {
return nilOption
}
return func(ctx Context) ([]common.MapStr, Context) {
return m, ctx
}
}
func nilOption(o Context) ([]common.MapStr, Context) {
return nil, o
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/sqos/beats.git
git@gitee.com:sqos/beats.git
sqos
beats
beats
v5.6.11

搜索帮助

0d507c66 1850385 C8b1a773 1850385