message_bus 0.9.3 → 0.9.3.1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of message_bus might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/.travis.yml +2 -0
- data/CHANGELOG +6 -1
- data/Gemfile +1 -0
- data/assets/message-bus.js +59 -23
- data/lib/message_bus/version.rb +1 -1
- data/vendor/assets/javascripts/message-bus.js +59 -23
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e3736140cfa912b949f2a89f3929d71f2b3c827a
|
4
|
+
data.tar.gz: 518e68f6fdec5bf02d04f2eb4a3f5d9284dc8cf1
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bc301c324e6a2caa0ae6b405e64e3f1984827b776a029400b76d2862d1ac8c764c6918f93bbc4ccba20100837b9ba4dc86064f53f3de16ce0c3200a59bd47a73
|
7
|
+
data.tar.gz: c18d8a2a00553724c5b18d588afd95f5348c7e9e68f79ac844abd89c26631e35eba19e4435e88d601056f7b150bd51bb5b1f175e576a3929e4f39aa1baa4beed
|
data/.travis.yml
CHANGED
data/CHANGELOG
CHANGED
@@ -1,4 +1,9 @@
|
|
1
|
-
12-
|
1
|
+
05-12-2013
|
2
|
+
- Version 0.9.3.1
|
3
|
+
- Add MessageBus.diagnostics() for diagnosing bus issues client side
|
4
|
+
- Add more robustness to JavaScript, if callbacks used to fail they would halt the chain
|
5
|
+
|
6
|
+
03-12-2013
|
2
7
|
- Version 0.9.3
|
3
8
|
- Remove thin dependency
|
4
9
|
- Improve robustness under failure conditions
|
data/Gemfile
CHANGED
data/assets/message-bus.js
CHANGED
@@ -9,7 +9,7 @@
|
|
9
9
|
**/
|
10
10
|
window.MessageBus = (function() {
|
11
11
|
// http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript
|
12
|
-
var callbacks, clientId, failCount,
|
12
|
+
var callbacks, clientId, failCount, shouldLongPoll, queue, responseCallbacks, uniqueId, baseUrl;
|
13
13
|
var me, started, stopped, longPoller, pollTimeout;
|
14
14
|
|
15
15
|
uniqueId = function() {
|
@@ -99,9 +99,15 @@ window.MessageBus = (function() {
|
|
99
99
|
return me.alwaysLongPoll || !isHidden();
|
100
100
|
};
|
101
101
|
|
102
|
+
var totalAjaxFailures = 0;
|
103
|
+
var totalAjaxCalls = 0;
|
104
|
+
var lastAjax;
|
105
|
+
|
102
106
|
longPoller = function(poll,data){
|
103
107
|
var gotData = false;
|
104
|
-
var
|
108
|
+
var aborted = false;
|
109
|
+
lastAjax = new Date();
|
110
|
+
totalAjaxCalls += 1;
|
105
111
|
|
106
112
|
return $.ajax(baseUrl + "message-bus/" + clientId + "/poll?" + (!shouldLongPoll() || !me.enableLongPolling ? "dlp=t" : ""), {
|
107
113
|
data: data,
|
@@ -118,7 +124,14 @@ window.MessageBus = (function() {
|
|
118
124
|
$.each(callbacks, function(_,callback) {
|
119
125
|
if (callback.channel === message.channel) {
|
120
126
|
callback.last_id = message.message_id;
|
121
|
-
|
127
|
+
try {
|
128
|
+
callback.func(message.data);
|
129
|
+
}
|
130
|
+
catch(e){
|
131
|
+
if(console.log) {
|
132
|
+
console.log("MESSAGE BUS FAIL: callback " + callback.channel + " caused exception " + e.message);
|
133
|
+
}
|
134
|
+
}
|
122
135
|
}
|
123
136
|
if (message.channel === "/__status") {
|
124
137
|
if (message.data[callback.channel] !== undefined) {
|
@@ -128,30 +141,45 @@ window.MessageBus = (function() {
|
|
128
141
|
});
|
129
142
|
});
|
130
143
|
},
|
131
|
-
error:
|
132
|
-
|
133
|
-
|
134
|
-
pollTimeout = setTimeout(poll, 100);
|
144
|
+
error: function(xhr, textStatus, err) {
|
145
|
+
if(textStatus === "abort") {
|
146
|
+
aborted = true;
|
135
147
|
} else {
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
if (interval > me.maxPollInterval) {
|
145
|
-
interval = me.maxPollInterval;
|
146
|
-
}
|
147
|
-
|
148
|
-
interval -= (new Date() - lastAjax);
|
149
|
-
if (interval < 100) {
|
148
|
+
failCount += 1;
|
149
|
+
totalAjaxFailures += 1;
|
150
|
+
}
|
151
|
+
},
|
152
|
+
complete: function() {
|
153
|
+
var interval;
|
154
|
+
try {
|
155
|
+
if (gotData || aborted) {
|
150
156
|
interval = 100;
|
151
|
-
}
|
157
|
+
} else {
|
158
|
+
interval = me.callbackInterval;
|
159
|
+
if (failCount > 2) {
|
160
|
+
interval = interval * failCount;
|
161
|
+
} else if (!shouldLongPoll()) {
|
162
|
+
// slowing down stuff a lot when hidden
|
163
|
+
// we will need to fine tune this
|
164
|
+
interval = interval * 4;
|
165
|
+
}
|
166
|
+
if (interval > me.maxPollInterval) {
|
167
|
+
interval = me.maxPollInterval;
|
168
|
+
}
|
152
169
|
|
153
|
-
|
170
|
+
interval -= (new Date() - lastAjax);
|
171
|
+
|
172
|
+
if (interval < 100) {
|
173
|
+
interval = 100;
|
174
|
+
}
|
175
|
+
}
|
176
|
+
} catch(e) {
|
177
|
+
if(console.log && e.message) {
|
178
|
+
console.log("MESSAGE BUS FAIL: " + e.message);
|
179
|
+
}
|
154
180
|
}
|
181
|
+
|
182
|
+
pollTimeout = setTimeout(poll, interval);
|
155
183
|
me.longPoll = null;
|
156
184
|
}
|
157
185
|
});
|
@@ -166,6 +194,14 @@ window.MessageBus = (function() {
|
|
166
194
|
alwaysLongPoll: false,
|
167
195
|
baseUrl: baseUrl,
|
168
196
|
|
197
|
+
diagnostics: function(){
|
198
|
+
console.log("Stopped: " + stopped + " Started: " + started);
|
199
|
+
console.log("Current callbacks");
|
200
|
+
console.log(callbacks);
|
201
|
+
console.log("Total ajax calls: " + totalAjaxCalls + " Recent failure count: " + failCount + " Total failures: " + totalAjaxFailures);
|
202
|
+
console.log("Last ajax call: " + (new Date() - lastAjax) / 1000 + " seconds ago") ;
|
203
|
+
},
|
204
|
+
|
169
205
|
stop: function() {
|
170
206
|
stopped = true;
|
171
207
|
started = false;
|
data/lib/message_bus/version.rb
CHANGED
@@ -9,7 +9,7 @@
|
|
9
9
|
**/
|
10
10
|
window.MessageBus = (function() {
|
11
11
|
// http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript
|
12
|
-
var callbacks, clientId, failCount,
|
12
|
+
var callbacks, clientId, failCount, shouldLongPoll, queue, responseCallbacks, uniqueId, baseUrl;
|
13
13
|
var me, started, stopped, longPoller, pollTimeout;
|
14
14
|
|
15
15
|
uniqueId = function() {
|
@@ -99,9 +99,15 @@ window.MessageBus = (function() {
|
|
99
99
|
return me.alwaysLongPoll || !isHidden();
|
100
100
|
};
|
101
101
|
|
102
|
+
var totalAjaxFailures = 0;
|
103
|
+
var totalAjaxCalls = 0;
|
104
|
+
var lastAjax;
|
105
|
+
|
102
106
|
longPoller = function(poll,data){
|
103
107
|
var gotData = false;
|
104
|
-
var
|
108
|
+
var aborted = false;
|
109
|
+
lastAjax = new Date();
|
110
|
+
totalAjaxCalls += 1;
|
105
111
|
|
106
112
|
return $.ajax(baseUrl + "message-bus/" + clientId + "/poll?" + (!shouldLongPoll() || !me.enableLongPolling ? "dlp=t" : ""), {
|
107
113
|
data: data,
|
@@ -118,7 +124,14 @@ window.MessageBus = (function() {
|
|
118
124
|
$.each(callbacks, function(_,callback) {
|
119
125
|
if (callback.channel === message.channel) {
|
120
126
|
callback.last_id = message.message_id;
|
121
|
-
|
127
|
+
try {
|
128
|
+
callback.func(message.data);
|
129
|
+
}
|
130
|
+
catch(e){
|
131
|
+
if(console.log) {
|
132
|
+
console.log("MESSAGE BUS FAIL: callback " + callback.channel + " caused exception " + e.message);
|
133
|
+
}
|
134
|
+
}
|
122
135
|
}
|
123
136
|
if (message.channel === "/__status") {
|
124
137
|
if (message.data[callback.channel] !== undefined) {
|
@@ -128,30 +141,45 @@ window.MessageBus = (function() {
|
|
128
141
|
});
|
129
142
|
});
|
130
143
|
},
|
131
|
-
error:
|
132
|
-
|
133
|
-
|
134
|
-
pollTimeout = setTimeout(poll, 100);
|
144
|
+
error: function(xhr, textStatus, err) {
|
145
|
+
if(textStatus === "abort") {
|
146
|
+
aborted = true;
|
135
147
|
} else {
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
141
|
-
|
142
|
-
|
143
|
-
|
144
|
-
if (interval > me.maxPollInterval) {
|
145
|
-
interval = me.maxPollInterval;
|
146
|
-
}
|
147
|
-
|
148
|
-
interval -= (new Date() - lastAjax);
|
149
|
-
if (interval < 100) {
|
148
|
+
failCount += 1;
|
149
|
+
totalAjaxFailures += 1;
|
150
|
+
}
|
151
|
+
},
|
152
|
+
complete: function() {
|
153
|
+
var interval;
|
154
|
+
try {
|
155
|
+
if (gotData || aborted) {
|
150
156
|
interval = 100;
|
151
|
-
}
|
157
|
+
} else {
|
158
|
+
interval = me.callbackInterval;
|
159
|
+
if (failCount > 2) {
|
160
|
+
interval = interval * failCount;
|
161
|
+
} else if (!shouldLongPoll()) {
|
162
|
+
// slowing down stuff a lot when hidden
|
163
|
+
// we will need to fine tune this
|
164
|
+
interval = interval * 4;
|
165
|
+
}
|
166
|
+
if (interval > me.maxPollInterval) {
|
167
|
+
interval = me.maxPollInterval;
|
168
|
+
}
|
152
169
|
|
153
|
-
|
170
|
+
interval -= (new Date() - lastAjax);
|
171
|
+
|
172
|
+
if (interval < 100) {
|
173
|
+
interval = 100;
|
174
|
+
}
|
175
|
+
}
|
176
|
+
} catch(e) {
|
177
|
+
if(console.log && e.message) {
|
178
|
+
console.log("MESSAGE BUS FAIL: " + e.message);
|
179
|
+
}
|
154
180
|
}
|
181
|
+
|
182
|
+
pollTimeout = setTimeout(poll, interval);
|
155
183
|
me.longPoll = null;
|
156
184
|
}
|
157
185
|
});
|
@@ -166,6 +194,14 @@ window.MessageBus = (function() {
|
|
166
194
|
alwaysLongPoll: false,
|
167
195
|
baseUrl: baseUrl,
|
168
196
|
|
197
|
+
diagnostics: function(){
|
198
|
+
console.log("Stopped: " + stopped + " Started: " + started);
|
199
|
+
console.log("Current callbacks");
|
200
|
+
console.log(callbacks);
|
201
|
+
console.log("Total ajax calls: " + totalAjaxCalls + " Recent failure count: " + failCount + " Total failures: " + totalAjaxFailures);
|
202
|
+
console.log("Last ajax call: " + (new Date() - lastAjax) / 1000 + " seconds ago") ;
|
203
|
+
},
|
204
|
+
|
169
205
|
stop: function() {
|
170
206
|
stopped = true;
|
171
207
|
started = false;
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: message_bus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.3
|
4
|
+
version: 0.9.3.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sam Saffron
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-12-
|
11
|
+
date: 2013-12-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|
@@ -124,7 +124,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
124
124
|
version: '0'
|
125
125
|
requirements: []
|
126
126
|
rubyforge_project:
|
127
|
-
rubygems_version: 2.0.
|
127
|
+
rubygems_version: 2.0.14
|
128
128
|
signing_key:
|
129
129
|
specification_version: 4
|
130
130
|
summary: ''
|