| OLD | NEW |
| 1 <!-- | 1 <!-- |
| 2 Copyright 2016 The LUCI Authors. All rights reserved. | 2 Copyright 2016 The LUCI Authors. All rights reserved. |
| 3 Use of this source code is governed under the Apache License, Version 2.0 | 3 Use of this source code is governed under the Apache License, Version 2.0 |
| 4 that can be found in the LICENSE file. | 4 that can be found in the LICENSE file. |
| 5 --> | 5 --> |
| 6 | 6 |
| 7 <link rel="import" href="../bower_components/polymer/polymer.html"> | 7 <link rel="import" href="../bower_components/polymer/polymer.html"> |
| 8 <link rel="import" href="../rpc/rpc-client.html"> | 8 <link rel="import" href="../rpc/rpc-client.html"> |
| 9 <link rel="import" href="../logdog-stream/logdog-stream.html"> | 9 <link rel="import" href="../logdog-stream/logdog-stream.html"> |
| 10 <link rel="import" href="../logdog-stream/logdog-error.html"> |
| 10 | 11 |
| 11 <!-- | 12 <!-- |
| 12 A class for issuing a LogDog query. | 13 A class for issuing a LogDog query. |
| 13 --> | 14 --> |
| 14 <script> | 15 <script> |
| 15 "use strict"; | 16 "use strict"; |
| 16 | 17 |
| 17 function LogDogQueryParams(project) { | 18 function LogDogQueryParams(project) { |
| 18 this.project = project; | 19 this.project = project; |
| 19 | 20 |
| (...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 140 this.client.service = "logdog.Logs"; | 141 this.client.service = "logdog.Logs"; |
| 141 this.client.method = "Query"; | 142 this.client.method = "Query"; |
| 142 this.client.request = body; | 143 this.client.request = body; |
| 143 | 144 |
| 144 return this.client.call().completes.then(function(resp) { | 145 return this.client.call().completes.then(function(resp) { |
| 145 resp = resp.response; | 146 resp = resp.response; |
| 146 | 147 |
| 147 // Normalize the JSON values in "desc". | 148 // Normalize the JSON values in "desc". |
| 148 // | 149 // |
| 149 // JSONPB timestamps are in the form of RFC3339 strings. | 150 // JSONPB timestamps are in the form of RFC3339 strings. |
| 150 (resp.streams || []).forEach(function(s) { | 151 resp.streams = (resp.streams || []); |
| 152 resp.streams.forEach(function(s) { |
| 151 s.stream = new LogDogStream(project, s.path); | 153 s.stream = new LogDogStream(project, s.path); |
| 152 if (s.state) { | 154 if (s.state) { |
| 153 patchState(s.state); | 155 patchState(s.state); |
| 154 } | 156 } |
| 155 if (s.desc) { | 157 if (s.desc) { |
| 156 patchDescriptor(s.desc); | 158 patchDescriptor(s.desc); |
| 157 } | 159 } |
| 158 }); | 160 }); |
| 159 return resp; | 161 return resp; |
| 162 }).catch(function(error) { |
| 163 throw LogDogError.wrapGrpc(error); |
| 160 }); | 164 }); |
| 161 }; | 165 }; |
| 162 | 166 |
| 163 /** | 167 /** |
| 164 * Issues a query and iteratively pulls up to "this.limit" results. | 168 * Issues a query and iteratively pulls up to "this.limit" results. |
| 165 */ | 169 */ |
| 166 LogDogQuery.prototype.getAll = function(limit) { | 170 LogDogQuery.prototype.getAll = function(limit) { |
| 167 var streams = []; | 171 var streams = []; |
| 168 var cursor = null; | 172 var cursor = null; |
| 169 limit = (limit || 100); | 173 limit = (limit || 100); |
| (...skipping 10 matching lines...) Expand all Loading... |
| 180 | 184 |
| 181 return this.get(cursor, remaining).then(function(resp) { | 185 return this.get(cursor, remaining).then(function(resp) { |
| 182 cursor = resp.next; | 186 cursor = resp.next; |
| 183 return fetchRound(resp.streams); | 187 return fetchRound(resp.streams); |
| 184 }); | 188 }); |
| 185 }.bind(this); | 189 }.bind(this); |
| 186 | 190 |
| 187 return fetchRound(null); | 191 return fetchRound(null); |
| 188 }; | 192 }; |
| 189 </script> | 193 </script> |
| OLD | NEW |