Browse code

Engine: integer job status, improved stream API

* Jobs return an integer status instead of a string
* Status convention mimics unix process execution: 0=success, 1=generic error, 127="no such command"
* Stdout and Stderr support multiple thread-safe data receivers and ring buffer filtering

Solomon Hykes authored on 2013/11/20 16:37:03
Showing 2 changed files
... ...
@@ -24,7 +24,7 @@ type Job struct {
24 24
 	Eng     *Engine
25 25
 	Name    string
26 26
 	Args    []string
27
-	env	*Env
27
+	env     *Env
28 28
 	Stdout  *Output
29 29
 	Stderr  *Output
30 30
 	Stdin   *Input
... ...
@@ -168,7 +168,7 @@ func Tail(src io.Reader, n int, dst *[]string) {
168 168
 // AddEnv starts a new goroutine which will decode all subsequent data
169 169
 // as a stream of json-encoded objects, and point `dst` to the last
170 170
 // decoded object.
171
-// The result `env` can be queried using the type-neutral Env interface. 
171
+// The result `env` can be queried using the type-neutral Env interface.
172 172
 // It is not safe to query `env` until the Output is closed.
173 173
 func (o *Output) AddEnv() (dst *Env, err error) {
174 174
 	src, err := o.AddPipe()
... ...
@@ -185,9 +185,8 @@ func (o *Output) AddEnv() (dst *Env, err error) {
185 185
 			if err != nil {
186 186
 				return
187 187
 			}
188
-			*dst= *env
188
+			*dst = *env
189 189
 		}
190 190
 	}()
191 191
 	return dst, nil
192 192
 }
193
-