| 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 logdog | 5 package logdog |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "errors" | 8 "errors" |
| 9 "fmt" | 9 "fmt" |
| 10 "net/http" | 10 "net/http" |
| 11 "net/url" | 11 "net/url" |
| 12 "strings" | 12 "strings" |
| 13 "time" | 13 "time" |
| 14 | 14 |
| 15 "github.com/luci/luci-go/common/config" | |
| 16 log "github.com/luci/luci-go/common/logging" | 15 log "github.com/luci/luci-go/common/logging" |
| 17 "github.com/luci/luci-go/common/proto/google" | 16 "github.com/luci/luci-go/common/proto/google" |
| 18 miloProto "github.com/luci/luci-go/common/proto/milo" | 17 miloProto "github.com/luci/luci-go/common/proto/milo" |
| 19 "github.com/luci/luci-go/grpc/grpcutil" | 18 "github.com/luci/luci-go/grpc/grpcutil" |
| 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/coordinator" | 20 "github.com/luci/luci-go/logdog/client/coordinator" |
| 22 "github.com/luci/luci-go/logdog/common/types" | 21 "github.com/luci/luci-go/logdog/common/types" |
| 22 "github.com/luci/luci-go/luci_config/common/cfgtypes" |
| 23 "github.com/luci/luci-go/milo/api/resp" | 23 "github.com/luci/luci-go/milo/api/resp" |
| 24 "github.com/luci/luci-go/milo/appengine/logdog/internal" | 24 "github.com/luci/luci-go/milo/appengine/logdog/internal" |
| 25 "github.com/luci/luci-go/milo/common/miloerror" | 25 "github.com/luci/luci-go/milo/common/miloerror" |
| 26 | 26 |
| 27 "github.com/golang/protobuf/proto" | 27 "github.com/golang/protobuf/proto" |
| 28 mc "github.com/luci/gae/service/memcache" | 28 mc "github.com/luci/gae/service/memcache" |
| 29 "golang.org/x/net/context" | 29 "golang.org/x/net/context" |
| 30 "google.golang.org/grpc/codes" | 30 "google.golang.org/grpc/codes" |
| 31 ) | 31 ) |
| 32 | 32 |
| 33 const ( | 33 const ( |
| 34 // intermediateCacheLifetime is the amount of time to cache intermediate
(non- | 34 // intermediateCacheLifetime is the amount of time to cache intermediate
(non- |
| 35 // terminal) annotation streams. Terminal annotation streams are cached | 35 // terminal) annotation streams. Terminal annotation streams are cached |
| 36 // indefinitely. | 36 // indefinitely. |
| 37 intermediateCacheLifetime = 10 * time.Second | 37 intermediateCacheLifetime = 10 * time.Second |
| 38 | 38 |
| 39 // defaultLogDogHost is the default LogDog host, if one isn't specified
via | 39 // defaultLogDogHost is the default LogDog host, if one isn't specified
via |
| 40 // query string. | 40 // query string. |
| 41 defaultLogDogHost = "luci-logdog.appspot.com" | 41 defaultLogDogHost = "luci-logdog.appspot.com" |
| 42 ) | 42 ) |
| 43 | 43 |
| 44 type annotationStreamRequest struct { | 44 type annotationStreamRequest struct { |
| 45 *AnnotationStream | 45 *AnnotationStream |
| 46 | 46 |
| 47 // host is the name of the LogDog host. | 47 // host is the name of the LogDog host. |
| 48 host string | 48 host string |
| 49 | 49 |
| 50 » project config.ProjectName | 50 » project cfgtypes.ProjectName |
| 51 path types.StreamPath | 51 path types.StreamPath |
| 52 | 52 |
| 53 // logDogClient is the HTTP client to use for LogDog communication. | 53 // logDogClient is the HTTP client to use for LogDog communication. |
| 54 logDogClient *coordinator.Client | 54 logDogClient *coordinator.Client |
| 55 | 55 |
| 56 // cs is the unmarshalled annotation stream Step and associated data. | 56 // cs is the unmarshalled annotation stream Step and associated data. |
| 57 cs internal.CachedStep | 57 cs internal.CachedStep |
| 58 } | 58 } |
| 59 | 59 |
| 60 func (as *annotationStreamRequest) normalize() error { | 60 func (as *annotationStreamRequest) normalize() error { |
| (...skipping 211 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 272 prefix: prefix, | 272 prefix: prefix, |
| 273 } | 273 } |
| 274 ) | 274 ) |
| 275 AddLogDogToBuild(c, &ub, streams.MainStream.Data, &build) | 275 AddLogDogToBuild(c, &ub, streams.MainStream.Data, &build) |
| 276 return &build | 276 return &build |
| 277 } | 277 } |
| 278 | 278 |
| 279 type logDogURLBuilder struct { | 279 type logDogURLBuilder struct { |
| 280 host string | 280 host string |
| 281 prefix types.StreamName | 281 prefix types.StreamName |
| 282 » project config.ProjectName | 282 » project cfgtypes.ProjectName |
| 283 } | 283 } |
| 284 | 284 |
| 285 func (b *logDogURLBuilder) BuildLink(l *miloProto.Link) *resp.Link { | 285 func (b *logDogURLBuilder) BuildLink(l *miloProto.Link) *resp.Link { |
| 286 switch t := l.Value.(type) { | 286 switch t := l.Value.(type) { |
| 287 case *miloProto.Link_LogdogStream: | 287 case *miloProto.Link_LogdogStream: |
| 288 ls := t.LogdogStream | 288 ls := t.LogdogStream |
| 289 | 289 |
| 290 server := ls.Server | 290 server := ls.Server |
| 291 if server == "" { | 291 if server == "" { |
| 292 server = b.host | 292 server = b.host |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 324 if link.Label == "" { | 324 if link.Label == "" { |
| 325 link.Label = "unnamed" | 325 link.Label = "unnamed" |
| 326 } | 326 } |
| 327 return &link | 327 return &link |
| 328 | 328 |
| 329 default: | 329 default: |
| 330 // Don't know how to render. | 330 // Don't know how to render. |
| 331 return nil | 331 return nil |
| 332 } | 332 } |
| 333 } | 333 } |
| OLD | NEW |