| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 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 | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package services | 5 package services |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "time" | 8 "time" |
| 9 | 9 |
| 10 "github.com/golang/protobuf/proto" | 10 "github.com/golang/protobuf/proto" |
| 11 ds "github.com/luci/gae/service/datastore" | 11 ds "github.com/luci/gae/service/datastore" |
| 12 "github.com/luci/luci-go/appengine/logdog/coordinator" | 12 "github.com/luci/luci-go/appengine/logdog/coordinator" |
| 13 "github.com/luci/luci-go/appengine/logdog/coordinator/endpoints" |
| 13 "github.com/luci/luci-go/appengine/logdog/coordinator/hierarchy" | 14 "github.com/luci/luci-go/appengine/logdog/coordinator/hierarchy" |
| 14 "github.com/luci/luci-go/appengine/logdog/coordinator/mutations" | 15 "github.com/luci/luci-go/appengine/logdog/coordinator/mutations" |
| 15 "github.com/luci/luci-go/appengine/tumble" | 16 "github.com/luci/luci-go/appengine/tumble" |
| 16 "github.com/luci/luci-go/common/api/logdog_coordinator/services/v1" | 17 "github.com/luci/luci-go/common/api/logdog_coordinator/services/v1" |
| 17 "github.com/luci/luci-go/common/clock" | 18 "github.com/luci/luci-go/common/clock" |
| 18 "github.com/luci/luci-go/common/grpcutil" | 19 "github.com/luci/luci-go/common/grpcutil" |
| 19 "github.com/luci/luci-go/common/logdog/types" | 20 "github.com/luci/luci-go/common/logdog/types" |
| 20 log "github.com/luci/luci-go/common/logging" | 21 log "github.com/luci/luci-go/common/logging" |
| 21 "github.com/luci/luci-go/common/proto/logdog/logpb" | 22 "github.com/luci/luci-go/common/proto/logdog/logpb" |
| 22 "golang.org/x/net/context" | 23 "golang.org/x/net/context" |
| (...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 68 log.Fields{ | 69 log.Fields{ |
| 69 "project": req.Project, | 70 "project": req.Project, |
| 70 "path": path, | 71 "path": path, |
| 71 }.Infof(c, "Registration request for log stream.") | 72 }.Infof(c, "Registration request for log stream.") |
| 72 | 73 |
| 73 if err := desc.Validate(true); err != nil { | 74 if err := desc.Validate(true); err != nil { |
| 74 return nil, grpcutil.Errf(codes.InvalidArgument, "Invalid log st
ream descriptor: %s", err) | 75 return nil, grpcutil.Errf(codes.InvalidArgument, "Invalid log st
ream descriptor: %s", err) |
| 75 } | 76 } |
| 76 prefix, _ := path.Split() | 77 prefix, _ := path.Split() |
| 77 | 78 |
| 78 » // Load our config and archive expiration. | 79 » // Load our service and project configs. |
| 79 cfg, err := coordinator.GetServices(c).Config(c) | 80 cfg, err := coordinator.GetServices(c).Config(c) |
| 80 if err != nil { | 81 if err != nil { |
| 81 log.WithError(err).Errorf(c, "Failed to load configuration.") | 82 log.WithError(err).Errorf(c, "Failed to load configuration.") |
| 82 return nil, grpcutil.Internal | 83 return nil, grpcutil.Internal |
| 83 } | 84 } |
| 84 | 85 |
| 85 » archiveDelayMax := cfg.Coordinator.ArchiveDelayMax.Duration() | 86 » pcfg, err := coordinator.CurrentProjectConfig(c) |
| 86 » if archiveDelayMax < 0 { | 87 » if err != nil { |
| 87 » » log.Fields{ | 88 » » log.WithError(err).Errorf(c, "Failed to load current project con
figuration.") |
| 88 » » » "archiveDelayMax": archiveDelayMax, | |
| 89 » » }.Errorf(c, "Must have positive maximum archive delay.") | |
| 90 return nil, grpcutil.Internal | 89 return nil, grpcutil.Internal |
| 91 } | 90 } |
| 92 | 91 |
| 92 // Determine the archival expiration. |
| 93 archiveDelayMax := endpoints.MinDuration(cfg.Coordinator.ArchiveDelayMax
, pcfg.MaxStreamAge) |
| 94 |
| 93 // Register our Prefix. | 95 // Register our Prefix. |
| 94 // | 96 // |
| 95 // This will also verify that our request secret matches the registered
one, | 97 // This will also verify that our request secret matches the registered
one, |
| 96 // if one is registered. | 98 // if one is registered. |
| 97 // | 99 // |
| 98 // Note: This step will not be necessary once a "register prefix" RPC ca
ll is | 100 // Note: This step will not be necessary once a "register prefix" RPC ca
ll is |
| 99 // implemented. | 101 // implemented. |
| 100 lsp := logStreamPrefix{ | 102 lsp := logStreamPrefix{ |
| 101 prefix: string(prefix), | 103 prefix: string(prefix), |
| 102 secret: req.Secret, | 104 secret: req.Secret, |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 240 return nil, grpcutil.Internal | 242 return nil, grpcutil.Internal |
| 241 } | 243 } |
| 242 } | 244 } |
| 243 | 245 |
| 244 return nil, nil | 246 return nil, nil |
| 245 } | 247 } |
| 246 | 248 |
| 247 func (m *registerStreamMutation) Root(c context.Context) *ds.Key { | 249 func (m *registerStreamMutation) Root(c context.Context) *ds.Key { |
| 248 return ds.Get(c).KeyForObj(m.ls) | 250 return ds.Get(c).KeyForObj(m.ls) |
| 249 } | 251 } |
| OLD | NEW |