1 Star 0 Fork 0

zhangjungang/beats

Create your Gitee Account
Explore and code with more than 13.5 million developers,Free private repositories !:)
Sign up
文件
Clone or Download
limit.go 577 Bytes
Copy Edit Raw Blame History
Nicolas Ruflin authored 2016-07-25 23:00 +08:00 . Refactor processors and readers (#2088)
package reader
// LimitProcessor sets an upper limited on line length. Lines longer
// then the max configured line length will be snapped short.
type Limit struct {
reader Reader
maxBytes int
}
// NewLimit creates a new reader limiting the line length.
func NewLimit(r Reader, maxBytes int) *Limit {
return &Limit{reader: r, maxBytes: maxBytes}
}
// Next returns the next line.
func (p *Limit) Next() (Message, error) {
message, err := p.reader.Next()
if len(message.Content) > p.maxBytes {
message.Content = message.Content[:p.maxBytes]
}
return message, err
}
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/zhangjungang/beats.git
git@gitee.com:zhangjungang/beats.git
zhangjungang
beats
beats
v5.6.3

Search