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

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

Issue 2435113002: LogDog: Add Storage-layer data caching. (Closed)
Patch Set: Fix byteLimit bug. Created 4 years, 1 month 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 luciConfig "github.com/luci/luci-go/common/config" 8 luciConfig "github.com/luci/luci-go/common/config"
9 "github.com/luci/luci-go/common/gcloud/gs" 9 "github.com/luci/luci-go/common/gcloud/gs"
10 "github.com/luci/luci-go/logdog/api/config/svcconfig" 10 "github.com/luci/luci-go/logdog/api/config/svcconfig"
11 "github.com/luci/luci-go/logdog/appengine/coordinator" 11 "github.com/luci/luci-go/logdog/appengine/coordinator"
12 "github.com/luci/luci-go/logdog/appengine/coordinator/config" 12 "github.com/luci/luci-go/logdog/appengine/coordinator/config"
13 "github.com/luci/luci-go/logdog/common/storage" 13 "github.com/luci/luci-go/logdog/common/storage"
14 "github.com/luci/luci-go/logdog/common/storage/caching"
14 "golang.org/x/net/context" 15 "golang.org/x/net/context"
15 ) 16 )
16 17
17 // Services is a testing stub for a coordinator.Services instance that allows 18 // Services is a testing stub for a coordinator.Services instance that allows
18 // the user to configure the various services that are returned. 19 // the user to configure the various services that are returned.
19 type Services struct { 20 type Services struct {
20 // C, if not nil, will be used to get the return values for Config, over riding 21 // C, if not nil, will be used to get the return values for Config, over riding
21 // local static members. 22 // local static members.
22 C func() (*config.Config, error) 23 C func() (*config.Config, error)
23 24
24 // PC, if not nil, will be used to get the return values for ProjectConf ig, 25 // PC, if not nil, will be used to get the return values for ProjectConf ig,
25 // overriding local static members. 26 // overriding local static members.
26 PC func() (*svcconfig.ProjectConfig, error) 27 PC func() (*svcconfig.ProjectConfig, error)
27 28
28 // Storage returns an intermediate storage instance for use by this serv ice. 29 // Storage returns an intermediate storage instance for use by this serv ice.
29 // 30 //
30 // The caller must close the returned instance if successful. 31 // The caller must close the returned instance if successful.
31 IS func() (storage.Storage, error) 32 IS func() (storage.Storage, error)
32 33
33 // GSClient instantiates a Google Storage client. 34 // GSClient instantiates a Google Storage client.
34 GS func() (gs.Client, error) 35 GS func() (gs.Client, error)
35 36
36 // ArchivalPublisher returns an ArchivalPublisher instance. 37 // ArchivalPublisher returns an ArchivalPublisher instance.
37 AP func() (coordinator.ArchivalPublisher, error) 38 AP func() (coordinator.ArchivalPublisher, error)
39
40 // SC returns a storage caching.Cache instance. If nil, a nil cache valu e
41 // will be returned.
42 SC func() caching.Cache
38 } 43 }
39 44
40 var _ coordinator.Services = (*Services)(nil) 45 var _ coordinator.Services = (*Services)(nil)
41 46
42 // Config implements coordinator.Services. 47 // Config implements coordinator.Services.
43 func (s *Services) Config(c context.Context) (*config.Config, error) { 48 func (s *Services) Config(c context.Context) (*config.Config, error) {
44 if s.C != nil { 49 if s.C != nil {
45 return s.C() 50 return s.C()
46 } 51 }
47 return config.Load(c) 52 return config.Load(c)
48 } 53 }
49 54
50 // ProjectConfig implements coordinator.Services. 55 // ProjectConfig implements coordinator.Services.
51 func (s *Services) ProjectConfig(c context.Context, project luciConfig.ProjectNa me) (*svcconfig.ProjectConfig, error) { 56 func (s *Services) ProjectConfig(c context.Context, project luciConfig.ProjectNa me) (*svcconfig.ProjectConfig, error) {
52 if s.PC != nil { 57 if s.PC != nil {
53 return s.PC() 58 return s.PC()
54 } 59 }
55 return config.ProjectConfig(c, project) 60 return config.ProjectConfig(c, project)
56 } 61 }
57 62
58 // IntermediateStorage implements coordinator.Services. 63 // IntermediateStorage implements coordinator.Services.
59 func (s *Services) IntermediateStorage(context.Context) (storage.Storage, error) { 64 func (s *Services) IntermediateStorage(c context.Context) (storage.Storage, erro r) {
60 if s.IS != nil { 65 if s.IS != nil {
61 return s.IS() 66 return s.IS()
62 } 67 }
63 panic("not implemented") 68 panic("not implemented")
64 } 69 }
65 70
66 // GSClient implements coordinator.Services. 71 // GSClient implements coordinator.Services.
67 func (s *Services) GSClient(context.Context) (gs.Client, error) { 72 func (s *Services) GSClient(context.Context) (gs.Client, error) {
68 if s.GS != nil { 73 if s.GS != nil {
69 return s.GS() 74 return s.GS()
70 } 75 }
71 panic("not implemented") 76 panic("not implemented")
72 } 77 }
73 78
74 // ArchivalPublisher implements coordinator.Services. 79 // ArchivalPublisher implements coordinator.Services.
75 func (s *Services) ArchivalPublisher(context.Context) (coordinator.ArchivalPubli sher, error) { 80 func (s *Services) ArchivalPublisher(context.Context) (coordinator.ArchivalPubli sher, error) {
76 if s.AP != nil { 81 if s.AP != nil {
77 return s.AP() 82 return s.AP()
78 } 83 }
79 panic("not implemented") 84 panic("not implemented")
80 } 85 }
86
87 // StorageCache implements coordinator.Services.
88 func (s *Services) StorageCache() caching.Cache {
89 if s.SC != nil {
90 return s.SC()
91 }
92 return nil
93 }
OLDNEW
« no previous file with comments | « logdog/appengine/coordinator/coordinatorTest/context.go ('k') | logdog/appengine/coordinator/coordinatorTest/storage_cache.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698