1 Star 0 Fork 0

zhangjungang/beats

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
prospector_stdin.go 883 Bytes
一键复制 编辑 原始数据 按行查看 历史
package crawler
import (
"fmt"
"time"
"github.com/elastic/beats/filebeat/harvester"
"github.com/elastic/beats/filebeat/input"
)
type ProspectorStdin struct {
Prospector *Prospector
harvester *harvester.Harvester
started bool
}
func NewProspectorStdin(p *Prospector) (*ProspectorStdin, error) {
prospectorer := &ProspectorStdin{
Prospector: p,
}
var err error
prospectorer.harvester, err = p.createHarvester("-", &input.FileStat{})
if err != nil {
return nil, fmt.Errorf("Error initializing stdin harvester: %v", err)
}
return prospectorer, nil
}
func (p *ProspectorStdin) Init() {
p.started = false
}
func (p *ProspectorStdin) Run() {
// Make sure stdin harvester is only started once
if !p.started {
p.harvester.Start()
p.started = true
}
// Wait time during endless loop
oneSecond, _ := time.ParseDuration("1s")
time.Sleep(oneSecond)
}
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/zhangjungang/beats.git
git@gitee.com:zhangjungang/beats.git
zhangjungang
beats
beats
v5.0.0-alpha2

搜索帮助