3761: Pass pullq to RunPullWorker
authorRadhika Chippada <radhika@curoverse.com>
Tue, 3 Mar 2015 17:57:31 +0000 (12:57 -0500)
committerRadhika Chippada <radhika@curoverse.com>
Tue, 3 Mar 2015 17:57:31 +0000 (12:57 -0500)
services/keepstore/keepstore.go
services/keepstore/pull_worker.go
services/keepstore/pull_worker_test.go

index ca796676f3964ddb10a31fd60917442e7809f9bd..1e8c3d1e0fbd62f9dea1a2efce54a0a73b911a41 100644 (file)
@@ -288,7 +288,7 @@ func main() {
        }
 
        pullq = NewWorkQueue()
-       go RunPullWorker(pullq.NextItem, keepClient)
+       go RunPullWorker(pullq, keepClient)
 
        // Shut down the server gracefully (by closing the listener)
        // if SIGTERM is received.
index dced531bf5fb08ac8bd808818ca8bf021128de31..db1d756ad8748ea0b365a296e2a0a162fed15747 100644 (file)
@@ -22,7 +22,8 @@ var keepClient keepclient.KeepClient
                        Skip the rest of the servers if no errors
                Repeat
 */
-func RunPullWorker(nextItem <-chan interface{}, kc keepclient.KeepClient) {
+func RunPullWorker(pullq *WorkQueue, kc keepclient.KeepClient) {
+       nextItem := pullq.NextItem
        keepClient = kc
        for item := range nextItem {
                Pull(item.(PullRequest))
index 84e951c454334fc5f7e10921ed2a2b9dab0650f3..962f2b1e0a10c1034ff5aad3870fcb3a44300020 100644 (file)
@@ -33,7 +33,7 @@ func (s *PullWorkerTestSuite) SetUpSuite(c *C) {
        c.Assert(err, Equals, nil)
        keepClient, err := keepclient.MakeKeepClient(&arv)
        c.Assert(err, Equals, nil)
-       go RunPullWorker(pullq.NextItem, keepClient)
+       go RunPullWorker(pullq, keepClient)
 
        // When a new pull request arrives, the old one will be overwritten.
        // This behavior is simulated with delay tests below.
@@ -42,7 +42,7 @@ func (s *PullWorkerTestSuite) SetUpSuite(c *C) {
 }
 
 func (s *PullWorkerTestSuite) TearDownSuite(c *C) {
-       // give the channel enough time to read and process all pull list entries
+       // give the channel some time to read and process all pull list entries
        time.Sleep(1000 * time.Millisecond)
 
        expectWorkerChannelEmpty(c, pullq.NextItem)
@@ -232,7 +232,7 @@ func performTest(testData PullWorkerTestData, c *C) {
        // We need to make sure the tests have a slight delay so that we can verify the pull list channel overwrites.
        time.Sleep(25 * time.Millisecond)
 
-       // Override GetContent to mock keepclient functionality
+       // Override GetContent to mock keepclient Get functionality
        GetContent = func(locator string, signedLocator string) (reader io.ReadCloser, contentLength int64, url string, err error) {
                if strings.HasPrefix(testData.name, "TestPullWorker_pull_list_with_one_locator_with_delay") {
                        time.Sleep(100 * time.Millisecond)