1 Star 0 Fork 0

zhangjungang/beats

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
克隆/下载
encode.go 816 Bytes
一键复制 编辑 原始数据 按行查看 历史
Nicolas Ruflin 提交于 2016-08-15 12:06 . Cleanup Line reader (#2166)
package reader
import (
"io"
"time"
"github.com/elastic/beats/filebeat/harvester/encoding"
)
// Encode reader produces lines by reading lines from an io.Reader
// through a decoder converting the reader it's encoding to utf-8.
type Encode struct {
reader *Line
}
// NewEncode creates a new Encode reader from input reader by applying
// the given codec.
func NewEncode(
reader io.Reader,
codec encoding.Encoding,
bufferSize int,
) (Encode, error) {
r, err := NewLine(reader, codec, bufferSize)
return Encode{r}, err
}
// Next reads the next line from it's initial io.Reader
// This converts a io.Reader to a reader.reader
func (p Encode) Next() (Message, error) {
c, sz, err := p.reader.Next()
// Creating message object
return Message{
Ts: time.Now(),
Content: c,
Bytes: sz,
}, err
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/zhangjungang/beats.git
git@gitee.com:zhangjungang/beats.git
zhangjungang
beats
beats
v5.5.2

搜索帮助