1 Star 0 Fork 0

zhangjungang/beats

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
filestat.go 1015 Bytes
一键复制 编辑 原始数据 按行查看 历史
ruflin 提交于 2016-02-10 18:23 +08:00 . Cleanup and simplify prospector and harvester
package harvester
import "os"
// Contains statistic about file when it was last seend by the prospector
type FileStat struct {
Fileinfo os.FileInfo /* the file info */
Return chan int64 /* the harvester will send an event with its offset when it closes */
LastIteration uint32 /* int number of the last iterations in which we saw this file */
}
func NewFileStat(fi os.FileInfo, lastIteration uint32) *FileStat {
fs := &FileStat{
Fileinfo: fi,
Return: make(chan int64, 1),
LastIteration: lastIteration,
}
return fs
}
func (fs *FileStat) Finished() bool {
return len(fs.Return) != 0
}
// Ignore forgets about the previous harvester results and let it continue on the old
// file - start a new channel to use with the new harvester.
func (fs *FileStat) Ignore() {
fs.Return = make(chan int64, 1)
}
func (fs *FileStat) Continue(old *FileStat) {
if old != nil {
fs.Return = old.Return
}
}
func (fs *FileStat) Skip(returnOffset int64) {
fs.Return <- returnOffset
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/zhangjungang/beats.git
git@gitee.com:zhangjungang/beats.git
zhangjungang
beats
beats
v5.0.0-alpha1

搜索帮助