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

Side by Side Diff: logdog/server/service/config/config.go

Issue 2626433004: Move "common/config" common types into cfgtypes. (Closed)
Patch Set: Created 3 years, 11 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
« no previous file with comments | « logdog/server/collector/utils_test.go ('k') | logdog/server/service/service.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The LUCI Authors. All rights reserved. 1 // Copyright 2016 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 config 5 package config
6 6
7 import ( 7 import (
8 "errors" 8 "errors"
9 "fmt" 9 "fmt"
10 "time" 10 "time"
11 11
12 "github.com/golang/protobuf/proto"
13 "github.com/luci/luci-go/common/clock" 12 "github.com/luci/luci-go/common/clock"
14 "github.com/luci/luci-go/common/config" 13 "github.com/luci/luci-go/common/config"
15 "github.com/luci/luci-go/common/data/caching/proccache" 14 "github.com/luci/luci-go/common/data/caching/proccache"
16 log "github.com/luci/luci-go/common/logging" 15 log "github.com/luci/luci-go/common/logging"
17 "github.com/luci/luci-go/logdog/api/config/svcconfig" 16 "github.com/luci/luci-go/logdog/api/config/svcconfig"
17 "github.com/luci/luci-go/luci_config/common/cfgtypes"
18
19 "github.com/golang/protobuf/proto"
18 "golang.org/x/net/context" 20 "golang.org/x/net/context"
19 ) 21 )
20 22
21 // Options is the set of options used to set up a Manager. 23 // Options is the set of options used to set up a Manager.
22 // 24 //
23 // The configuration is loaded from a svcconfig.Config protobuf. 25 // The configuration is loaded from a svcconfig.Config protobuf.
24 type Options struct { 26 type Options struct {
25 // Config is the configuration service to load from. 27 // Config is the configuration service to load from.
26 Config config.Interface 28 Config config.Interface
27 29
(...skipping 114 matching lines...) Expand 10 before | Expand all | Expand 10 after
142 144
143 return &m, nil 145 return &m, nil
144 } 146 }
145 147
146 // Config returns the service configuration instance. 148 // Config returns the service configuration instance.
147 func (m *Manager) Config() *svcconfig.Config { 149 func (m *Manager) Config() *svcconfig.Config {
148 return &m.cfg 150 return &m.cfg
149 } 151 }
150 152
151 // ProjectConfig returns the project configuration. 153 // ProjectConfig returns the project configuration.
152 func (m *Manager) ProjectConfig(c context.Context, project config.ProjectName) ( *svcconfig.ProjectConfig, error) { 154 func (m *Manager) ProjectConfig(c context.Context, project cfgtypes.ProjectName) (*svcconfig.ProjectConfig, error) {
153 serviceID := m.o.ServiceID 155 serviceID := m.o.ServiceID
154 if serviceID == "" { 156 if serviceID == "" {
155 return nil, errors.New("no service ID specified") 157 return nil, errors.New("no service ID specified")
156 } 158 }
157 159
158 v, err := proccache.GetOrMake(c, project, func() (interface{}, time.Dura tion, error) { 160 v, err := proccache.GetOrMake(c, project, func() (interface{}, time.Dura tion, error) {
159 configSet := fmt.Sprintf("projects/%s", project) 161 configSet := fmt.Sprintf("projects/%s", project)
160 configPath := fmt.Sprintf("%s.cfg", serviceID) 162 configPath := fmt.Sprintf("%s.cfg", serviceID)
161 cfg, err := m.o.Config.GetConfig(c, configSet, configPath, false ) 163 cfg, err := m.o.Config.GetConfig(c, configSet, configPath, false )
162 if err != nil { 164 if err != nil {
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
216 if err := proto.UnmarshalText(cfg.Content, &m.cfg); err != nil { 218 if err := proto.UnmarshalText(cfg.Content, &m.cfg); err != nil {
217 log.Fields{ 219 log.Fields{
218 log.ErrorKey: err, 220 log.ErrorKey: err,
219 "hash": cfg.ContentHash, 221 "hash": cfg.ContentHash,
220 }.Errorf(c, "Failed to unmarshal configuration.") 222 }.Errorf(c, "Failed to unmarshal configuration.")
221 return err 223 return err
222 } 224 }
223 m.cfgHash = cfg.ContentHash 225 m.cfgHash = cfg.ContentHash
224 return nil 226 return nil
225 } 227 }
OLDNEW
« no previous file with comments | « logdog/server/collector/utils_test.go ('k') | logdog/server/service/service.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698