forked from taggledevel2/ratchet
-
Notifications
You must be signed in to change notification settings - Fork 1
/
file_reader.go
33 lines (26 loc) · 845 Bytes
/
file_reader.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
package processors
import (
"io/ioutil"
"github.com/dailyburn/ratchet/data"
"github.com/dailyburn/ratchet/util"
)
// FileReader opens and reads the contents of the given filename.
type FileReader struct {
filename string
}
// NewFileReader returns a new FileReader that will read the entire contents
// of the given file path and send it at once. For buffered or line-by-line
// reading try using IoReader.
func NewFileReader(filename string) *FileReader {
return &FileReader{filename: filename}
}
func (r *FileReader) ProcessData(d data.JSON, outputChan chan data.JSON, killChan chan error) {
d, err := ioutil.ReadFile(r.filename)
util.KillPipelineIfErr(err, killChan)
outputChan <- d
}
func (r *FileReader) Finish(outputChan chan data.JSON, killChan chan error) {
}
func (r *FileReader) String() string {
return "FileReader"
}