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

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

Issue 1863973002: LogDog: Update to archival V2. (Closed) Base URL: https://github.com/luci/luci-go@grpcutil-errors
Patch Set: Code review comments, use Pub/Sub, archival staging, quality of life. Created 4 years, 8 months 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
(Empty)
1 // Copyright 2015 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
4
5 package coordinatorTest
6
7 import (
8 "errors"
9
10 "github.com/luci/luci-go/appengine/logdog/coordinator"
11 "github.com/luci/luci-go/appengine/logdog/coordinator/config"
12 "github.com/luci/luci-go/common/gcloud/gs"
13 "github.com/luci/luci-go/common/proto/logdog/svcconfig"
14 "github.com/luci/luci-go/server/logdog/storage"
15 "golang.org/x/net/context"
16 )
17
18 // Services is a testing stub for a coordinator.Services instance that allows
19 // the user to configure the various services that are returned.
20 type Services struct {
21 // GlobalConfig is the global configuration to return from Config.
22 GlobalConfig *config.GlobalConfig
23 // ServiceConfig is the service configuration to return from Config.
24 ServiceConfig *svcconfig.Config
25
26 // C, if not nil, will be used to get the return values for Config, over riding
27 // local static members.
28 C func() (*config.GlobalConfig, *svcconfig.Config, error)
29
30 // Storage returns an intermediate storage instance for use by this serv ice.
31 //
32 // The caller must close the returned instance if successful.
33 IS func() (storage.Storage, error)
34
35 // GSClient instantiates a Google Storage client.
36 GS func() (gs.Client, error)
37
38 // ArchivalPublisher returns an ArchivalPublisher instance.
39 AP func() (coordinator.ArchivalPublisher, error)
40 }
41
42 var _ coordinator.Services = (*Services)(nil)
43
44 // Config implements coordinator.Services.
45 func (s *Services) Config(context.Context) (*config.GlobalConfig, *svcconfig.Con fig, error) {
46 if s.C != nil {
47 return s.C()
48 }
49 if s.GlobalConfig == nil || s.ServiceConfig == nil {
50 return nil, nil, errors.New("not configured")
51 }
52 return s.GlobalConfig, s.ServiceConfig, nil
53 }
54
55 // IntermediateStorage implements coordinator.Services.
56 func (s *Services) IntermediateStorage(context.Context) (storage.Storage, error) {
57 if s.IS != nil {
58 return s.IS()
59 }
60 panic("not implemented")
61 }
62
63 // GSClient implements coordinator.Services.
64 func (s *Services) GSClient(context.Context) (gs.Client, error) {
65 if s.GS != nil {
66 return s.GS()
67 }
68 panic("not implemented")
69 }
70
71 // ArchivalPublisher implements coordinator.Services.
72 func (s *Services) ArchivalPublisher(context.Context) (coordinator.ArchivalPubli sher, error) {
73 if s.AP != nil {
74 return s.AP()
75 }
76 panic("not implemented")
77 }
78
79 // InitConfig loads default testing GlobalConfig and ServiceConfig values.
80 func (s *Services) InitConfig() {
81 s.GlobalConfig = &config.GlobalConfig{
82 ConfigServiceURL: "https://example.com",
83 ConfigSet: "services/logdog-test",
84 ConfigPath: "coordinator-test.cfg",
85 }
86
87 s.ServiceConfig = &svcconfig.Config{
88 Coordinator: &svcconfig.Coordinator{},
89 }
90 }
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698