-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbuilder.go
80 lines (60 loc) · 2 KB
/
builder.go
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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
package pipeline
import (
"io"
)
func Build() Builder {
return newInputBuilder()
}
type Builder interface {
FromFile(path string) InputBuilder
FromWeb(url string) InputBuilder
FromReader(r io.Reader, size int64) InputBuilder
}
type InputBuilder interface {
// Enable decompression of the input with gzip
DecompressGzip(enable bool) InputBuilder
Decode(decoder Processor) InputBuilder
// Add a ProgressBar to the pipeline
// The io.Writer will get updated
ProgressBar(register ProgressBarRegistrator) InputBuilder
OutputBuilder
// parsing
ParseLines(parser LineParser[[]byte]) InputBuilder
ParseLinesToGob(parser LineParser[interface{}]) InputBuilder
ParseLinesToJson(parser LineParser[interface{}]) InputBuilder
ParseLinesToCustomEncoder(encoder NewEncoder, parser LineParser[interface{}]) InputBuilder
Fanout() FanoutBuilder
}
type ReadonlyBuilder interface {
AddReadonlyProcessor(p Processor) ReadonlyBuilder
Build() Pipeline
}
type OutputBuilder interface {
// Only read the pipeline
ReadOnly() ReadonlyBuilder
// Output the pipeline into a file
ToFile(path string) OutputConfigurationBuilder
// Output the pipeline into a new file or if exists append to it
AppendToFile(path string) OutputConfigurationBuilder
// Output the pipeline into any io.Writer
ToWriter(w io.Writer) OutputConfigurationBuilder
}
type OutputConfigurationBuilder interface {
Preamble(preamble string) OutputConfigurationBuilder
Appendix(appendix string) OutputConfigurationBuilder
CompressGzip(enable bool) OutputConfigurationBuilder
AddProcessingStep(p Processor) OutputConfigurationBuilder
Build() Pipeline
}
type FanoutBuilder interface {
Register(func(output OutputBuilder) Pipeline) FanoutBuilder
Build() Pipeline
}
type Pipeline interface {
Execute() error
}
type readerStep (func(next Reader) Reader)
type consumeReaderWithSize func(next ReaderWithSize) error
type consumeReader func(next Reader) error
type connectorToReader func(next Connector) Reader
type makeReaderWithSize func(next Reader) ReaderWithSize