| 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 hierarchy | 5 package hierarchy |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "crypto/sha256" | 8 "crypto/sha256" |
| 9 "encoding/base64" | 9 "encoding/base64" |
| 10 "encoding/hex" | 10 "encoding/hex" |
| 11 | 11 |
| 12 ds "github.com/luci/gae/service/datastore" | |
| 13 log "github.com/luci/luci-go/common/logging" | 12 log "github.com/luci/luci-go/common/logging" |
| 14 "github.com/luci/luci-go/grpc/grpcutil" | 13 "github.com/luci/luci-go/grpc/grpcutil" |
| 15 "github.com/luci/luci-go/logdog/appengine/coordinator" | 14 "github.com/luci/luci-go/logdog/appengine/coordinator" |
| 16 "github.com/luci/luci-go/logdog/common/types" | 15 "github.com/luci/luci-go/logdog/common/types" |
| 17 "github.com/luci/luci-go/luci_config/common/cfgtypes" | 16 "github.com/luci/luci-go/luci_config/common/cfgtypes" |
| 18 | 17 |
| 18 ds "github.com/luci/gae/service/datastore" |
| 19 |
| 19 "golang.org/x/net/context" | 20 "golang.org/x/net/context" |
| 20 "google.golang.org/grpc/codes" | 21 "google.golang.org/grpc/codes" |
| 21 ) | 22 ) |
| 22 | 23 |
| 23 // componentEntity is a hierarchial component that stores a specific log path | 24 // componentEntity is a hierarchial component that stores a specific log path |
| 24 // component. A given stream path is broken into components, each of which is | 25 // component. A given stream path is broken into components, each of which is |
| 25 // represented by a single componentEntity. | 26 // represented by a single componentEntity. |
| 26 // | 27 // |
| 27 // A componentEntity is keyed based on its path component name and the hash of | 28 // A componentEntity is keyed based on its path component name and the hash of |
| 28 // its parent component's path. This ensures that the set of child components | 29 // its parent component's path. This ensures that the set of child components |
| (...skipping 242 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 271 | 272 |
| 272 return ds.NewKey(c, "_StreamNameComponent", string(d), 0, nil), nil | 273 return ds.NewKey(c, "_StreamNameComponent", string(d), 0, nil), nil |
| 273 } | 274 } |
| 274 | 275 |
| 275 // cursorForKey returns a cursor for the supplied componentID. This cursor will | 276 // cursorForKey returns a cursor for the supplied componentID. This cursor will |
| 276 // start new queries at the component immediately following this ID. | 277 // start new queries at the component immediately following this ID. |
| 277 func cursorForKey(c context.Context, e *componentEntity) string { | 278 func cursorForKey(c context.Context, e *componentEntity) string { |
| 278 key := ds.KeyForObj(c, e) | 279 key := ds.KeyForObj(c, e) |
| 279 return base64.URLEncoding.EncodeToString([]byte(key.StringID())) | 280 return base64.URLEncoding.EncodeToString([]byte(key.StringID())) |
| 280 } | 281 } |
| OLD | NEW |