-/*
- Keepstore initiates pull worker channel goroutine.
- The channel will process pull list.
- For each (next) pull request:
- For each locator listed, execute Pull on the server(s) listed
- Skip the rest of the servers if no errors
- Repeat
-*/
-func RunPullWorker(nextItem <-chan interface{}, kc keepclient.KeepClient) {
- keepClient = kc
- for item := range nextItem {
- Pull(item.(PullRequest))
+// RunPullWorker receives PullRequests from pullq, invokes
+// PullItemAndProcess on each one. After each PR, it logs a message
+// indicating whether the pull was successful.
+func RunPullWorker(pullq *WorkQueue, keepClient *keepclient.KeepClient) {
+ for item := range pullq.NextItem {
+ pr := item.(PullRequest)
+ err := PullItemAndProcess(pr, keepClient)
+ pullq.DoneItem <- struct{}{}
+ if err == nil {
+ log.Printf("Pull %s success", pr)
+ } else {
+ log.Printf("Pull %s error: %s", pr, err)
+ }