refactor: logparser v5 to pkgs

This commit is contained in:
Inanc Gumus
2019-08-28 23:46:42 +03:00
parent 4629b59ef2
commit 81b4246973
26 changed files with 601 additions and 458 deletions

29
logparser/v5/pipe/pipe.go Normal file
View File

@ -0,0 +1,29 @@
// For more tutorials: https://blog.learngoprogramming.com
//
// Copyright © 2018 Inanc Gumus
// Learn Go Programming Course
// License: https://creativecommons.org/licenses/by-nc-sa/4.0/
//
package pipe
// YieldFunc yields a record from an Iterator to up-stream (Consumer).
type YieldFunc = func(Record) error
// Iterator yields a record.
type Iterator interface {
Each(YieldFunc) error
}
// Consumer consumes records from an iterator.
type Consumer interface {
Consume(Iterator) error
}
// Transform represents both a record consumer and producer.
// It has an input and output.
// It takes a single record and provides an iterator for all the records.
type Transform interface {
Iterator // producer: should never return on yield().err == nil
Consumer
}