OLD | NEW |
1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 package coordinator | 5 package coordinator |
6 | 6 |
7 import ( | 7 import ( |
8 "errors" | 8 "errors" |
9 "fmt" | 9 "fmt" |
10 "time" | 10 "time" |
(...skipping 101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
112 | 112 |
113 // Get retrieves log stream entries from the Coordinator. The supplied | 113 // Get retrieves log stream entries from the Coordinator. The supplied |
114 // parameters shape which entries are requested and what information is | 114 // parameters shape which entries are requested and what information is |
115 // returned. | 115 // returned. |
116 func (s *Stream) Get(ctx context.Context, p *StreamGetParams) ([]*logpb.LogEntry
, error) { | 116 func (s *Stream) Get(ctx context.Context, p *StreamGetParams) ([]*logpb.LogEntry
, error) { |
117 if p == nil { | 117 if p == nil { |
118 p = &StreamGetParams{} | 118 p = &StreamGetParams{} |
119 } | 119 } |
120 | 120 |
121 req := p.r | 121 req := p.r |
| 122 req.Project = string(s.c.project) |
122 req.Path = string(s.path) | 123 req.Path = string(s.path) |
123 if p.stateP != nil { | 124 if p.stateP != nil { |
124 req.State = true | 125 req.State = true |
125 } | 126 } |
126 | 127 |
127 resp, err := s.c.C.Get(ctx, &req) | 128 resp, err := s.c.C.Get(ctx, &req) |
128 if err != nil { | 129 if err != nil { |
129 return nil, normalizeError(err) | 130 return nil, normalizeError(err) |
130 } | 131 } |
131 if err := loadStatePointer(p.stateP, resp); err != nil { | 132 if err := loadStatePointer(p.stateP, resp); err != nil { |
132 return nil, err | 133 return nil, err |
133 } | 134 } |
134 return resp.Logs, nil | 135 return resp.Logs, nil |
135 } | 136 } |
136 | 137 |
137 // Tail performs a tail call, returning the last log entry in the stream. If | 138 // Tail performs a tail call, returning the last log entry in the stream. If |
138 // stateP is not nil, the stream's state will be requested and loaded into the | 139 // stateP is not nil, the stream's state will be requested and loaded into the |
139 // variable. | 140 // variable. |
140 func (s *Stream) Tail(ctx context.Context, stateP *LogStream) (*logpb.LogEntry,
error) { | 141 func (s *Stream) Tail(ctx context.Context, stateP *LogStream) (*logpb.LogEntry,
error) { |
141 req := logdog.TailRequest{ | 142 req := logdog.TailRequest{ |
142 » » Path: string(s.path), | 143 » » Project: string(s.c.project), |
| 144 » » Path: string(s.path), |
143 } | 145 } |
144 if stateP != nil { | 146 if stateP != nil { |
145 req.State = true | 147 req.State = true |
146 } | 148 } |
147 | 149 |
148 resp, err := s.c.C.Tail(ctx, &req) | 150 resp, err := s.c.C.Tail(ctx, &req) |
149 if err != nil { | 151 if err != nil { |
150 return nil, normalizeError(err) | 152 return nil, normalizeError(err) |
151 } | 153 } |
152 if err := loadStatePointer(stateP, resp); err != nil { | 154 if err := loadStatePointer(stateP, resp); err != nil { |
(...skipping 20 matching lines...) Expand all Loading... |
173 if resp.Desc == nil { | 175 if resp.Desc == nil { |
174 return errors.New("Requested descriptor was not returned") | 176 return errors.New("Requested descriptor was not returned") |
175 } | 177 } |
176 if resp.State == nil { | 178 if resp.State == nil { |
177 return errors.New("Requested state was not returned") | 179 return errors.New("Requested state was not returned") |
178 } | 180 } |
179 ls := loadLogStream(resp.Desc.Path(), resp.State, resp.Desc) | 181 ls := loadLogStream(resp.Desc.Path(), resp.State, resp.Desc) |
180 *stateP = *ls | 182 *stateP = *ls |
181 return nil | 183 return nil |
182 } | 184 } |
OLD | NEW |