-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathexample_test.go
More file actions
37 lines (33 loc) · 831 Bytes
/
example_test.go
File metadata and controls
37 lines (33 loc) · 831 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
package someutils
import (
"fmt"
"io"
"strings"
)
type ExampleUtil struct {
}
func (ex *ExampleUtil) Exec(inPipe io.Reader, outPipe io.Writer, errPipe io.Writer) (error, int) {
err := LineProcessor(inPipe, outPipe, errPipe, func(inPipe io.Reader, outPipe io.Writer, errPipe io.Writer, line []byte) error {
_, err := fmt.Fprintln(outPipe, string(line))
return err
})
if err != nil {
return err, 1
}
return nil, 0
}
func ExamplePipeline() {
p := NewPipeline(&PipableSimpleWrapper{&ExampleUtil{}}, &PipableSimpleWrapper{&ExampleUtil{}})
mainInvocation, out, err := p.InvokeReader(strings.NewReader("Hi\nHo\nhI\nhO\n")) //, os.Stdout, os.Stderr)
//e, _ := p.Invoke(mainInvocation)
//<-e
//<-e
mainInvocation.Wait()
fmt.Println(out.String())
fmt.Println(err.String())
// Output:
// Hi
// Ho
// hI
// hO
}