Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(959)

Side by Side Diff: logdog/appengine/coordinator/coordinatorTest/archival.go

Issue 2582253002: logdog: Use gRPC credentials when creating PubSub client, not http.Client. (Closed)
Patch Set: clear gRPC metadata as a precation Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2015 The LUCI Authors. All rights reserved. 1 // Copyright 2015 The LUCI Authors. All rights reserved.
2 // Use of this source code is governed under the Apache License, Version 2.0 2 // Use of this source code is governed under the Apache License, Version 2.0
3 // that can be found in the LICENSE file. 3 // that can be found in the LICENSE file.
4 4
5 package coordinatorTest 5 package coordinatorTest
6 6
7 import ( 7 import (
8 "fmt"
8 "sort" 9 "sort"
9 "sync" 10 "sync"
10 11
11 "github.com/luci/luci-go/logdog/api/endpoints/coordinator/services/v1" 12 "github.com/luci/luci-go/logdog/api/endpoints/coordinator/services/v1"
12 "github.com/luci/luci-go/logdog/appengine/coordinator" 13 "github.com/luci/luci-go/logdog/appengine/coordinator"
13 "golang.org/x/net/context" 14 "golang.org/x/net/context"
14 ) 15 )
15 16
16 // ArchivalPublisher is a testing implementation of a 17 // ArchivalPublisher is a testing implementation of a
17 // coordinator.ArchivalPublisher. It records which archival tasks were 18 // coordinator.ArchivalPublisher. It records which archival tasks were
18 // scheduled and offers accessors to facilitate test assertions. 19 // scheduled and offers accessors to facilitate test assertions.
19 type ArchivalPublisher struct { 20 type ArchivalPublisher struct {
20 sync.Mutex 21 sync.Mutex
21 22
22 // Err, if not nil, is the error returned by Publish. 23 // Err, if not nil, is the error returned by Publish.
23 Err error 24 Err error
24 25
26 closed bool
25 tasks []*logdog.ArchiveTask 27 tasks []*logdog.ArchiveTask
26 archivalIndex uint64 28 archivalIndex uint64
27 } 29 }
28 30
29 var _ coordinator.ArchivalPublisher = (*ArchivalPublisher)(nil) 31 var _ coordinator.ArchivalPublisher = (*ArchivalPublisher)(nil)
30 32
33 func (ap *ArchivalPublisher) Close() error {
34 ap.Lock()
35 defer ap.Unlock()
36
37 if ap.closed {
38 return fmt.Errorf("already closed")
39 }
40 ap.closed = true
41
42 return nil
43 }
44
31 // Publish implements coordinator.ArchivalPublisher. 45 // Publish implements coordinator.ArchivalPublisher.
32 func (ap *ArchivalPublisher) Publish(c context.Context, at *logdog.ArchiveTask) error { 46 func (ap *ArchivalPublisher) Publish(c context.Context, at *logdog.ArchiveTask) error {
33 ap.Lock() 47 ap.Lock()
34 defer ap.Unlock() 48 defer ap.Unlock()
35 49
50 if ap.closed {
51 return fmt.Errorf("closed")
52 }
53
36 if err := ap.Err; err != nil { 54 if err := ap.Err; err != nil {
37 return err 55 return err
38 } 56 }
39 57
40 ap.tasks = append(ap.tasks, at) 58 ap.tasks = append(ap.tasks, at)
41 return nil 59 return nil
42 } 60 }
43 61
44 // NewPublishIndex implements coordinator.ArchivalPublisher. 62 // NewPublishIndex implements coordinator.ArchivalPublisher.
45 func (ap *ArchivalPublisher) NewPublishIndex() uint64 { 63 func (ap *ArchivalPublisher) NewPublishIndex() uint64 {
(...skipping 30 matching lines...) Expand all
76 sort.Strings(taskHashes) 94 sort.Strings(taskHashes)
77 return taskHashes 95 return taskHashes
78 } 96 }
79 97
80 // Clear clears recorded tasks. 98 // Clear clears recorded tasks.
81 func (ap *ArchivalPublisher) Clear() { 99 func (ap *ArchivalPublisher) Clear() {
82 ap.Lock() 100 ap.Lock()
83 defer ap.Unlock() 101 defer ap.Unlock()
84 ap.tasks = nil 102 ap.tasks = nil
85 } 103 }
OLDNEW
« no previous file with comments | « logdog/appengine/coordinator/archivalPublisher.go ('k') | logdog/appengine/coordinator/mutations/createArchiveTask.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698