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

Unified Diff: appengine/swarming/ui/res/imp/common/common-behavior.html

Issue 2497663003: Make silent task retries more obvious (Closed)
Patch Set: rebase Created 4 years, 1 month 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 side-by-side diff with in-line comments
Download patch
Index: appengine/swarming/ui/res/imp/common/common-behavior.html
diff --git a/appengine/swarming/ui/res/imp/common/common-behavior.html b/appengine/swarming/ui/res/imp/common/common-behavior.html
index 73560838b9602be758eda800dfdfe384d5f85914..e3db4d5d0239ae4cf5e679da195d35590b8a50e2 100644
--- a/appengine/swarming/ui/res/imp/common/common-behavior.html
+++ b/appengine/swarming/ui/res/imp/common/common-behavior.html
@@ -102,6 +102,54 @@
}.bind(this));
},
+ // _getJsonAsyncArr is the array analog to _getJsonAsync. For example,
+ // if there is an array that will contain multiple results rendered with
+ // a dom-repeat, _getJsonAsyncArr will make an XHR GET request and put
+ // the results into the given array at the index specified by idx.
+ //
+ // Prior to making this call, it is assumed that arr is initialized to be
+ // an array of empty (or filler) objects. busyArr be initialized in the
+ // same way. Due to how Polymer deals with arrays, arrays of primitives
+ // are not supported, thus clients observing busyArr should iterate over
+ // all objects in busyArr and test to see if busyArr[i].status is true.
+ //
+ // To avoid multiple requests clobering one another, an object _jsonAsync
+ // is created on "this" to debounce requests - the most recent request
+ // will win out.
+ _getJsonAsyncArr: function(idx, arr, url, busyArr, headers, params) {
+ if (!arr || !url || !busyArr) {
+ console.log("Need at least a polymer array to bind to, a busy element, and a url");
+ return;
+ }
+ var key = arr + ":" + idx;
+ this.splice(busyArr, idx, 1, {status:true});
+ var now = new Date();
+ this._jsonAsync = this._jsonAsync || {};
+ this._jsonAsync[key] = now;
+ if (params) {
+ url = url + "?" + sk.query.fromParamSet(params);
+ }
+ return sk.request("GET", url, "", headers).then(JSON.parse).then(function(json){
+ if (this._jsonAsync[key] !== now) {
+ console.log("ignoring result because a second request happened for ", key);
+ this.splice(busyArr, idx, 1, {status:false});
+ return;
+ }
+ this.splice(arr, idx, 1, json);
+ this.splice(busyArr, idx, 1, {status:false});
+ }.bind(this)).catch(function(reason){
+ console.log("Reason for failure of request to " + url, reason);
+
+ if (this._jsonAsync[key] !== now) {
+ console.log("ignoring failure because a second request happened.");
+ this.splice(busyArr, idx, 1, {status:false});
+ return;
+ }
+ this.splice(busyArr, idx, 1, {status:false});
+ return Promise.reject(reason);
+ }.bind(this));
+ },
+
_humanDuration: function(timeInSecs) {
return sk.human.strDuration(timeInSecs) || "0s";
},
« no previous file with comments | « appengine/swarming/ui/res/imp/botlist/bot-list.html ('k') | appengine/swarming/ui/res/imp/common/task-behavior.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698