| OLD | NEW |
| 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" | |
| 9 "github.com/luci/luci-go/logdog/api/config/svcconfig" | 8 "github.com/luci/luci-go/logdog/api/config/svcconfig" |
| 10 "github.com/luci/luci-go/logdog/appengine/coordinator" | 9 "github.com/luci/luci-go/logdog/appengine/coordinator" |
| 11 "github.com/luci/luci-go/logdog/appengine/coordinator/config" | 10 "github.com/luci/luci-go/logdog/appengine/coordinator/config" |
| 11 "github.com/luci/luci-go/luci_config/common/cfgtypes" |
| 12 | 12 |
| 13 "golang.org/x/net/context" | 13 "golang.org/x/net/context" |
| 14 ) | 14 ) |
| 15 | 15 |
| 16 // Services is a testing stub for a coordinator.Services instance that allows | 16 // Services is a testing stub for a coordinator.Services instance that allows |
| 17 // the user to configure the various services that are returned. | 17 // the user to configure the various services that are returned. |
| 18 type Services struct { | 18 type Services struct { |
| 19 // C, if not nil, will be used to get the return values for Config, over
riding | 19 // C, if not nil, will be used to get the return values for Config, over
riding |
| 20 // local static members. | 20 // local static members. |
| 21 C func() (*config.Config, error) | 21 C func() (*config.Config, error) |
| (...skipping 20 matching lines...) Expand all Loading... |
| 42 | 42 |
| 43 // Config implements coordinator.Services. | 43 // Config implements coordinator.Services. |
| 44 func (s *Services) Config(c context.Context) (*config.Config, error) { | 44 func (s *Services) Config(c context.Context) (*config.Config, error) { |
| 45 if s.C != nil { | 45 if s.C != nil { |
| 46 return s.C() | 46 return s.C() |
| 47 } | 47 } |
| 48 return config.Load(c) | 48 return config.Load(c) |
| 49 } | 49 } |
| 50 | 50 |
| 51 // ProjectConfig implements coordinator.Services. | 51 // ProjectConfig implements coordinator.Services. |
| 52 func (s *Services) ProjectConfig(c context.Context, project luciConfig.ProjectNa
me) (*svcconfig.ProjectConfig, error) { | 52 func (s *Services) ProjectConfig(c context.Context, project cfgtypes.ProjectName
) (*svcconfig.ProjectConfig, error) { |
| 53 if s.PC != nil { | 53 if s.PC != nil { |
| 54 return s.PC() | 54 return s.PC() |
| 55 } | 55 } |
| 56 return config.ProjectConfig(c, project) | 56 return config.ProjectConfig(c, project) |
| 57 } | 57 } |
| 58 | 58 |
| 59 // StorageForStream implements coordinator.Services. | 59 // StorageForStream implements coordinator.Services. |
| 60 func (s *Services) StorageForStream(c context.Context, lst *coordinator.LogStrea
mState) (coordinator.Storage, error) { | 60 func (s *Services) StorageForStream(c context.Context, lst *coordinator.LogStrea
mState) (coordinator.Storage, error) { |
| 61 if s.ST != nil { | 61 if s.ST != nil { |
| 62 return s.ST(lst) | 62 return s.ST(lst) |
| 63 } | 63 } |
| 64 panic("not implemented") | 64 panic("not implemented") |
| 65 } | 65 } |
| 66 | 66 |
| 67 // ArchivalPublisher implements coordinator.Services. | 67 // ArchivalPublisher implements coordinator.Services. |
| 68 func (s *Services) ArchivalPublisher(context.Context) (coordinator.ArchivalPubli
sher, error) { | 68 func (s *Services) ArchivalPublisher(context.Context) (coordinator.ArchivalPubli
sher, error) { |
| 69 if s.AP != nil { | 69 if s.AP != nil { |
| 70 return s.AP() | 70 return s.AP() |
| 71 } | 71 } |
| 72 panic("not implemented") | 72 panic("not implemented") |
| 73 } | 73 } |
| OLD | NEW |