MCPcopy Create free account
hub / github.com/AdRoll/baker / Reset

Method Reset

input/inpututils/fastreader_unix.go:45–80  ·  view source on GitHub ↗
(r io.Reader)

Source from the content-addressed store, hash-verified

43}
44
45func (fr *fastReader) Reset(r io.Reader) error {
46 if fr.close != nil {
47 fr.close()
48 }
49
50 cmd := exec.Command(fr.command[0], fr.command[1:]...)
51 cmd.Stdin = r
52 cmd.Stderr = &fr.stderr
53
54 rpipe, err := cmd.StdoutPipe()
55 if err != nil {
56 return err
57 }
58
59 // Don't get the process killed at CTRL+C
60 cmd.SysProcAttr = &syscall.SysProcAttr{
61 Setpgid: true,
62 }
63 err = cmd.Start()
64 if err != nil {
65 rpipe.Close()
66 return err
67 }
68
69 fr.ReadCloser = rpipe
70 fr.close = func() error {
71 rpipe.Close()
72 if err := cmd.Wait(); err != nil {
73 if _, ok := err.(*exec.ExitError); ok {
74 return errors.New(strings.TrimSpace(fr.stderr.String()))
75 }
76 }
77 return err
78 }
79 return nil
80}
81
82func (fr *fastReader) Close() error {
83 return fr.close()

Callers 9

newFastReaderFunction · 0.95
benchmarkTopologyFunction · 0.80
wrapStringFunction · 0.80
pushMethod · 0.80
pollQueueMethod · 0.80
ProcessRecordsMethod · 0.80
TestTCPChunksFunction · 0.80
BenchmarkGzipFunction · 0.80
BenchmarkFastGzipFunction · 0.80

Calls 4

CloseMethod · 0.65
StartMethod · 0.45
WaitMethod · 0.45
StringMethod · 0.45

Tested by 4

benchmarkTopologyFunction · 0.64
TestTCPChunksFunction · 0.64
BenchmarkGzipFunction · 0.64
BenchmarkFastGzipFunction · 0.64