OLD | NEW |
1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2017, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 import 'dart:async'; | 5 import 'dart:async'; |
6 import 'dart:io' hide HttpException; | 6 import 'dart:io' hide HttpException; |
7 | 7 |
8 import 'buildbot_data.dart'; | 8 import 'buildbot_data.dart'; |
9 import 'buildbot_loading.dart'; | 9 import 'buildbot_loading.dart'; |
10 import 'buildbot_structures.dart'; | 10 import 'buildbot_structures.dart'; |
(...skipping 10 matching lines...) Expand all Loading... |
21 /// Closes the client and cleans up its state. | 21 /// Closes the client and cleans up its state. |
22 void close(); | 22 void close(); |
23 } | 23 } |
24 | 24 |
25 /// Buildbot client that pulls build bot results through http. | 25 /// Buildbot client that pulls build bot results through http. |
26 class HttpBuildbotClient implements BuildbotClient { | 26 class HttpBuildbotClient implements BuildbotClient { |
27 final HttpClient _client = new HttpClient(); | 27 final HttpClient _client = new HttpClient(); |
28 | 28 |
29 @override | 29 @override |
30 Future<BuildResult> readResult(BuildUri buildUri) async { | 30 Future<BuildResult> readResult(BuildUri buildUri) async { |
31 try { | 31 Duration timeout; |
32 return await readBuildResultFromHttp(_client, buildUri); | 32 if (buildUri.buildNumber < 0) { |
33 } on HttpException { | 33 timeout = new Duration(seconds: 1); |
34 return null; | 34 } |
35 } on SocketException { | 35 |
36 return null; | 36 void skipToPreviousBuildNumber() { |
| 37 BuildUri prevBuildUri = buildUri.prev(); |
| 38 log('Skip build number ' |
| 39 '${buildUri.buildNumber} -> ${prevBuildUri.buildNumber}'); |
| 40 buildUri = buildUri.prev(); |
| 41 } |
| 42 |
| 43 while (true) { |
| 44 try { |
| 45 return await readBuildResultFromHttp(_client, buildUri, timeout); |
| 46 } on TimeoutException { |
| 47 if (timeout != null) { |
| 48 skipToPreviousBuildNumber(); |
| 49 continue; |
| 50 } |
| 51 return null; |
| 52 } on HttpException { |
| 53 if (timeout != null) { |
| 54 skipToPreviousBuildNumber(); |
| 55 continue; |
| 56 } |
| 57 return null; |
| 58 } on SocketException { |
| 59 return null; |
| 60 } |
37 } | 61 } |
38 } | 62 } |
39 | 63 |
40 int get mostRecentBuildNumber => -2; | 64 int get mostRecentBuildNumber => -1; |
41 | 65 |
42 @override | 66 @override |
43 void close() { | 67 void close() { |
44 _client.close(); | 68 _client.close(); |
45 } | 69 } |
46 } | 70 } |
47 | 71 |
48 /// Buildbot client that pulls build bot results through logdog. | 72 /// Buildbot client that pulls build bot results through logdog. |
49 class LogdogBuildbotClient implements BuildbotClient { | 73 class LogdogBuildbotClient implements BuildbotClient { |
50 Map<String, List<int>> _botBuildNumberCache = <String, List<int>>{}; | 74 Map<String, List<int>> _botBuildNumberCache = <String, List<int>>{}; |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
89 buildUri = buildUri.withBuildNumber(buildNumber); | 113 buildUri = buildUri.withBuildNumber(buildNumber); |
90 } | 114 } |
91 } | 115 } |
92 } | 116 } |
93 | 117 |
94 @override | 118 @override |
95 void close() { | 119 void close() { |
96 // Nothing to do. | 120 // Nothing to do. |
97 } | 121 } |
98 } | 122 } |
OLD | NEW |