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

Side by Side Diff: logdog/common/types/streamaddr.go

Issue 2717623002: Milo: Handle missing / transient LogDog failures. (Closed)
Patch Set: remote unnecessary code Created 3 years, 9 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 | « no previous file | milo/appengine/frontend/expectations/bootstrap-swarming.TestableBuild-build-pending-logdog.html » ('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 2017 The LUCI Authors. All rights reserved. 1 // Copyright 2017 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 types 5 package types
6 6
7 import ( 7 import (
8 "net/url" 8 "net/url"
9 "strings" 9 "strings"
10 10
11 "github.com/luci/luci-go/common/errors" 11 "github.com/luci/luci-go/common/errors"
12 "github.com/luci/luci-go/luci_config/common/cfgtypes" 12 "github.com/luci/luci-go/luci_config/common/cfgtypes"
13 ) 13 )
14 14
15 const logDogURLScheme = "logdog" 15 const logDogURLScheme = "logdog"
16 16
17 // StreamAddr is a fully-qualified LogDog stream address. 17 // StreamAddr is a fully-qualified LogDog stream address.
18 type StreamAddr struct { 18 type StreamAddr struct {
19 // Host is the LogDog host. 19 // Host is the LogDog host.
20 Host string 20 Host string
21 21
22 // Project is the LUCI project name that this log belongs to. 22 // Project is the LUCI project name that this log belongs to.
23 Project cfgtypes.ProjectName 23 Project cfgtypes.ProjectName
24 24
25 // Path is the LogDog stream path. 25 // Path is the LogDog stream path.
26 Path StreamPath 26 Path StreamPath
27 } 27 }
28 28
29 // String returns a string representation of this address.
30 func (s *StreamAddr) String() string { return s.URL().String() }
31
29 // URL returns a LogDog URL that represents this Stream. 32 // URL returns a LogDog URL that represents this Stream.
30 func (s *StreamAddr) URL() *url.URL { 33 func (s *StreamAddr) URL() *url.URL {
31 return &url.URL{ 34 return &url.URL{
32 Scheme: logDogURLScheme, 35 Scheme: logDogURLScheme,
33 Host: s.Host, 36 Host: s.Host,
34 Path: strings.Join([]string{"", string(s.Project), string(s.Pa th)}, "/"), 37 Path: strings.Join([]string{"", string(s.Project), string(s.Pa th)}, "/"),
35 } 38 }
36 } 39 }
37 40
38 // ParseURL parses a LogDog URL into a Stream. If the URL is malformed, or 41 // ParseURL parses a LogDog URL into a Stream. If the URL is malformed, or
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
71 } 74 }
72 75
73 if err := addr.Path.Validate(); err != nil { 76 if err := addr.Path.Validate(); err != nil {
74 return nil, errors.Annotate(err).Reason("invalid stream path: %( path)q"). 77 return nil, errors.Annotate(err).Reason("invalid stream path: %( path)q").
75 D("path", addr.Path). 78 D("path", addr.Path).
76 Err() 79 Err()
77 } 80 }
78 81
79 return &addr, nil 82 return &addr, nil
80 } 83 }
OLDNEW
« no previous file with comments | « no previous file | milo/appengine/frontend/expectations/bootstrap-swarming.TestableBuild-build-pending-logdog.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698