1 Star 0 Fork 0

zhangjungang/beats

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
flags.go 941 Bytes
一键复制 编辑 原始数据 按行查看 历史
package beat
// FlagsHandler is an interface that can optionally be implemented by a Beat
// if it needs to process command line flags on startup. If implemented, the
// HandleFlags method will be invoked after parsing the command line flags
// and before any of the Beater interface methods are invoked. There will be
// no callback when '-help' or '-version' are specified.
type FlagsHandler interface {
HandleFlags(*Beat) error // Handle any custom command line arguments.
}
type FlagsHandlerCallback func(*Beat) error
var handlers []FlagsHandler
func AddFlagsHandler(h FlagsHandler) {
handlers = append(handlers, h)
}
func AddFlagsCallback(cb func(*Beat) error) {
AddFlagsHandler(FlagsHandlerCallback(cb))
}
func handleFlags(b *Beat) error {
for _, h := range handlers {
err := h.HandleFlags(b)
if err != nil {
return err
}
}
return nil
}
func (cb FlagsHandlerCallback) HandleFlags(b *Beat) error {
return cb(b)
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/zhangjungang/beats.git
git@gitee.com:zhangjungang/beats.git
zhangjungang
beats
beats
v5.6.13

搜索帮助