| OLD | NEW |
| 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 collector | 5 package collector |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "bytes" | 8 "bytes" |
| 9 "crypto/sha256" | 9 "crypto/sha256" |
| 10 "encoding/hex" | 10 "encoding/hex" |
| 11 "errors" | 11 "errors" |
| 12 "fmt" | 12 "fmt" |
| 13 "sort" | 13 "sort" |
| 14 "strings" | 14 "strings" |
| 15 "sync" | 15 "sync" |
| 16 | 16 |
| 17 "github.com/luci/luci-go/common/clock" | 17 "github.com/luci/luci-go/common/clock" |
| 18 "github.com/luci/luci-go/common/config" | |
| 19 "github.com/luci/luci-go/common/proto/google" | 18 "github.com/luci/luci-go/common/proto/google" |
| 20 "github.com/luci/luci-go/logdog/api/logpb" | 19 "github.com/luci/luci-go/logdog/api/logpb" |
| 21 "github.com/luci/luci-go/logdog/client/butlerproto" | 20 "github.com/luci/luci-go/logdog/client/butlerproto" |
| 22 "github.com/luci/luci-go/logdog/common/storage" | 21 "github.com/luci/luci-go/logdog/common/storage" |
| 23 "github.com/luci/luci-go/logdog/common/types" | 22 "github.com/luci/luci-go/logdog/common/types" |
| 24 cc "github.com/luci/luci-go/logdog/server/collector/coordinator" | 23 cc "github.com/luci/luci-go/logdog/server/collector/coordinator" |
| 24 "github.com/luci/luci-go/luci_config/common/cfgtypes" |
| 25 | 25 |
| 26 "golang.org/x/net/context" | 26 "golang.org/x/net/context" |
| 27 ) | 27 ) |
| 28 | 28 |
| 29 var testSecret = bytes.Repeat([]byte{0x55}, types.PrefixSecretLength) | 29 var testSecret = bytes.Repeat([]byte{0x55}, types.PrefixSecretLength) |
| 30 | 30 |
| 31 type streamKey struct { | 31 type streamKey struct { |
| 32 project string | 32 project string |
| 33 id string | 33 id string |
| 34 } | 34 } |
| (...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 288 // followed by a a series of records to assert. This can either be a specific | 288 // followed by a a series of records to assert. This can either be a specific |
| 289 // integer index or an intexRange marking a closed range of indices. | 289 // integer index or an intexRange marking a closed range of indices. |
| 290 func shouldHaveStoredStream(actual interface{}, expected ...interface{}) string
{ | 290 func shouldHaveStoredStream(actual interface{}, expected ...interface{}) string
{ |
| 291 st := actual.(storage.Storage) | 291 st := actual.(storage.Storage) |
| 292 project := expected[0].(string) | 292 project := expected[0].(string) |
| 293 name := expected[1].(string) | 293 name := expected[1].(string) |
| 294 expected = expected[2:] | 294 expected = expected[2:] |
| 295 | 295 |
| 296 // Load all entries for this stream. | 296 // Load all entries for this stream. |
| 297 req := storage.GetRequest{ | 297 req := storage.GetRequest{ |
| 298 » » Project: config.ProjectName(project), | 298 » » Project: cfgtypes.ProjectName(project), |
| 299 Path: types.StreamPath(name), | 299 Path: types.StreamPath(name), |
| 300 } | 300 } |
| 301 | 301 |
| 302 entries := make(map[int]*logpb.LogEntry) | 302 entries := make(map[int]*logpb.LogEntry) |
| 303 var ierr error | 303 var ierr error |
| 304 err := st.Get(req, func(e *storage.Entry) bool { | 304 err := st.Get(req, func(e *storage.Entry) bool { |
| 305 var le *logpb.LogEntry | 305 var le *logpb.LogEntry |
| 306 if le, ierr = e.GetLogEntry(); ierr != nil { | 306 if le, ierr = e.GetLogEntry(); ierr != nil { |
| 307 return false | 307 return false |
| 308 } | 308 } |
| (...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 371 if len(failed) > 0 { | 371 if len(failed) > 0 { |
| 372 return strings.Join(failed, ", ") | 372 return strings.Join(failed, ", ") |
| 373 } | 373 } |
| 374 return "" | 374 return "" |
| 375 } | 375 } |
| 376 | 376 |
| 377 func idFromPath(path string) string { | 377 func idFromPath(path string) string { |
| 378 hash := sha256.Sum256([]byte(path)) | 378 hash := sha256.Sum256([]byte(path)) |
| 379 return hex.EncodeToString(hash[:]) | 379 return hex.EncodeToString(hash[:]) |
| 380 } | 380 } |
| OLD | NEW |