| 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 14 matching lines...) Expand all Loading... |
| 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 static const int maxSkips = 3; | 29 static const int maxSkips = 3; |
| 30 | 30 |
| 31 @override | 31 @override |
| 32 Future<BuildResult> readResult(BuildUri buildUri) async { | 32 Future<BuildResult> readResult(BuildUri buildUri) async { |
| 33 int skips = 0; | 33 int skips = 0; |
| 34 Duration timeout; | 34 Duration timeout; |
| 35 if (buildUri.buildNumber < 0) { | 35 timeout = new Duration(seconds: 1); |
| 36 timeout = new Duration(seconds: 1); | |
| 37 } | |
| 38 | 36 |
| 39 void skipToPreviousBuildNumber() { | 37 void skipToPreviousBuildNumber() { |
| 40 BuildUri prevBuildUri = buildUri.prev(); | 38 BuildUri prevBuildUri = buildUri.prev(); |
| 41 log('Skip build number on ${buildUri} -> ${prevBuildUri.buildNumber}'); | 39 String message = |
| 40 'Skip build number on ${buildUri} -> ${prevBuildUri.buildNumber}'; |
| 41 // Skipping is more serious with an absolute than a relative build. |
| 42 if (buildUri.buildNumber < 0) { |
| 43 log(message); |
| 44 } else { |
| 45 print(message); |
| 46 } |
| 42 buildUri = buildUri.prev(); | 47 buildUri = buildUri.prev(); |
| 43 } | 48 } |
| 44 | 49 |
| 45 while (true) { | 50 while (true) { |
| 46 try { | 51 try { |
| 47 return await readBuildResultFromHttp(_client, buildUri, timeout); | 52 return await readBuildResultFromHttp(_client, buildUri, timeout); |
| 48 } on TimeoutException { | 53 } on TimeoutException { |
| 49 if (timeout != null && skips < maxSkips) { | 54 if (timeout != null && skips < maxSkips) { |
| 50 skips++; | 55 skips++; |
| 51 skipToPreviousBuildNumber(); | 56 skipToPreviousBuildNumber(); |
| (...skipping 65 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 117 buildUri = buildUri.withBuildNumber(buildNumber); | 122 buildUri = buildUri.withBuildNumber(buildNumber); |
| 118 } | 123 } |
| 119 } | 124 } |
| 120 } | 125 } |
| 121 | 126 |
| 122 @override | 127 @override |
| 123 void close() { | 128 void close() { |
| 124 // Nothing to do. | 129 // Nothing to do. |
| 125 } | 130 } |
| 126 } | 131 } |
| OLD | NEW |