job pull: refactor + use Task API

refs #10
This commit is contained in:
Christian Schwarz
2017-12-26 22:05:20 +01:00
parent b69089a527
commit 7d89d1fb00
2 changed files with 47 additions and 49 deletions
-24
View File
@@ -3,7 +3,6 @@ package cmd
import (
"fmt"
"io"
"time"
"bytes"
"encoding/json"
@@ -26,29 +25,6 @@ const (
InitialReplPolicyAll InitialReplPolicy = "all"
)
func closeRPCWithTimeout(log Logger, remote rpc.RPCClient, timeout time.Duration, goodbye string) {
log.Info("closing rpc connection")
ch := make(chan error)
go func() {
ch <- remote.Close()
close(ch)
}()
var err error
select {
case <-time.After(timeout):
err = fmt.Errorf("timeout exceeded (%s)", timeout)
case closeRequestErr := <-ch:
err = closeRequestErr
}
if err != nil {
log.WithError(err).Error("error closing connection")
}
return
}
type Puller struct {
task *Task
Remote rpc.RPCClient