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

Side by Side Diff: logdog/client/coordinator/list.go

Issue 2991253004: [logdog] Remove list functionality. (Closed)
Patch Set: fix test Created 3 years, 4 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 | « logdog/client/coordinator/client_test.go ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright 2016 The LUCI Authors.
2 //
3 // Licensed under the Apache License, Version 2.0 (the "License");
4 // you may not use this file except in compliance with the License.
5 // You may obtain a copy of the License at
6 //
7 // http://www.apache.org/licenses/LICENSE-2.0
8 //
9 // Unless required by applicable law or agreed to in writing, software
10 // distributed under the License is distributed on an "AS IS" BASIS,
11 // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 // See the License for the specific language governing permissions and
13 // limitations under the License.
14
15 package coordinator
16
17 import (
18 "github.com/luci/luci-go/logdog/api/endpoints/coordinator/logs/v1"
19 "github.com/luci/luci-go/logdog/common/types"
20 "github.com/luci/luci-go/luci_config/common/cfgtypes"
21 "golang.org/x/net/context"
22 )
23
24 // ListResult is a single returned list entry.
25 type ListResult struct {
26 // Project is the project that this result is bound to.
27 Project cfgtypes.ProjectName
28 // PathBase is the base part of the list path. This will match the base that
29 // the list was pulled from.
30 PathBase types.StreamPath
31 // Name is the name of this component, relative to PathBase.
32 Name string
33 // Stream is true if this list component is a stream component. Otherwis e,
34 // it's an intermediate path component.
35 Stream bool
36
37 // State is the state of the log stream. This will be populated if this is a
38 // stream component and state was requested.
39 State *LogStream
40 }
41
42 // FullPath returns the full StreamPath of this result. If it is not a stream,
43 // it will return an empty path.
44 func (lr *ListResult) FullPath() types.StreamPath {
45 return types.StreamPath(lr.PathBase).Append(lr.Name)
46 }
47
48 // ListCallback is a callback method type that is used in list requests.
49 //
50 // If it returns false, additional callbacks and list requests will be aborted.
51 type ListCallback func(*ListResult) bool
52
53 // ListOptions is a set of list request options.
54 type ListOptions struct {
55 // StreamsOnly requests that only stream components are returned. Interm ediate
56 // path components will be omitted.
57 StreamsOnly bool
58 // State, if true, requests that the full log stream descriptor and stat e get
59 // included in returned stream list components.
60 State bool
61
62 // Purged, if true, requests that purged log streams are included in the list
63 // results. This will result in an error if the user is not privileged t o see
64 // purged logs.
65 Purged bool
66 }
67
68 // List executes a log stream hierarchy listing for the specified path.
69 //
70 // If project is the empty string, a top-level project listing will be returned.
71 func (c *Client) List(ctx context.Context, project cfgtypes.ProjectName, pathBas e string, o ListOptions, cb ListCallback) error {
72 req := logdog.ListRequest{
73 Project: string(project),
74 PathBase: pathBase,
75 StreamOnly: o.StreamsOnly,
76 State: o.State,
77 IncludePurged: o.Purged,
78 }
79
80 for {
81 resp, err := c.C.List(ctx, &req)
82 if err != nil {
83 return normalizeError(err)
84 }
85
86 for _, s := range resp.Components {
87 lr := ListResult{
88 Project: cfgtypes.ProjectName(resp.Project),
89 PathBase: types.StreamPath(resp.PathBase),
90 Name: s.Name,
91 }
92 switch s.Type {
93 case logdog.ListResponse_Component_PATH:
94 break
95
96 case logdog.ListResponse_Component_STREAM:
97 lr.Stream = true
98 if s.State != nil {
99 lr.State = loadLogStream(resp.Project, l r.FullPath(), s.State, s.Desc)
100 }
101
102 case logdog.ListResponse_Component_PROJECT:
103 lr.Project = cfgtypes.ProjectName(lr.Name)
104 }
105
106 if !cb(&lr) {
107 return nil
108 }
109 }
110
111 if resp.Next == "" {
112 return nil
113 }
114 req.Next = resp.Next
115 }
116 }
OLDNEW
« no previous file with comments | « logdog/client/coordinator/client_test.go ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698