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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: d450c8fa5786bffc21e2aeab7d1b6dbafdb23d83
4
- data.tar.gz: ee639c147780954a1890e3f2a6538a8207c783bb
3
+ metadata.gz: e3736140cfa912b949f2a89f3929d71f2b3c827a
4
+ data.tar.gz: 518e68f6fdec5bf02d04f2eb4a3f5d9284dc8cf1
5
5
  SHA512:
6
- metadata.gz: e33215b0f984896ab7aeaf20b0ac3a924c11cd18d6c7b9bac181984e861ba2524b31d0811ea8b3a64d166ab83ce21d082ae129b6d19f917aacadc3f7220a3d87
7
- data.tar.gz: b4a16132f005dcbe33b71d5cb6bad693b46bb7c407dbebbd0cd25bf02d8ec7fa1286888f878de6c8b7e118d897c842b76abcd3c8a90d0819ca288a3e211c6efa
6
+ metadata.gz: bc301c324e6a2caa0ae6b405e64e3f1984827b776a029400b76d2862d1ac8c764c6918f93bbc4ccba20100837b9ba4dc86064f53f3de16ce0c3200a59bd47a73
7
+ data.tar.gz: c18d8a2a00553724c5b18d588afd95f5348c7e9e68f79ac844abd89c26631e35eba19e4435e88d601056f7b150bd51bb5b1f175e576a3929e4f39aa1baa4beed
data/.travis.yml CHANGED
@@ -4,3 +4,5 @@ rvm:
4
4
  - 2.0.0
5
5
  gemfile:
6
6
  - Gemfile
7
+ services:
8
+ - redis-server
data/CHANGELOG CHANGED
@@ -1,4 +1,9 @@
1
- 12-03-2013
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
@@ -11,5 +11,6 @@ group :test do
11
11
  gem 'rb-inotify', require: RUBY_PLATFORM =~ /linux/i ? 'rb-inotify' : false
12
12
  gem 'rack'
13
13
  gem 'http_parser.rb'
14
+ gem 'thin'
14
15
  gem 'rack-test', require: 'rack/test'
15
16
  end
@@ -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, interval, shouldLongPoll, queue, responseCallbacks, uniqueId, baseUrl;
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 lastAjax = new Date();
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
- callback.func(message.data);
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: failCount += 1,
132
- complete: function() {
133
- if (gotData) {
134
- pollTimeout = setTimeout(poll, 100);
144
+ error: function(xhr, textStatus, err) {
145
+ if(textStatus === "abort") {
146
+ aborted = true;
135
147
  } else {
136
- interval = me.callbackInterval;
137
- if (failCount > 2) {
138
- interval = interval * failCount;
139
- } else if (!shouldLongPoll()) {
140
- // slowning down stuff a lot when hidden
141
- // we will need to add a lot of fine tuning here
142
- interval = interval * 4;
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
- pollTimeout = setTimeout(poll, interval);
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;
@@ -1,3 +1,3 @@
1
1
  module MessageBus
2
- VERSION = "0.9.3"
2
+ VERSION = "0.9.3.1"
3
3
  end
@@ -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, interval, shouldLongPoll, queue, responseCallbacks, uniqueId, baseUrl;
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 lastAjax = new Date();
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
- callback.func(message.data);
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: failCount += 1,
132
- complete: function() {
133
- if (gotData) {
134
- pollTimeout = setTimeout(poll, 100);
144
+ error: function(xhr, textStatus, err) {
145
+ if(textStatus === "abort") {
146
+ aborted = true;
135
147
  } else {
136
- interval = me.callbackInterval;
137
- if (failCount > 2) {
138
- interval = interval * failCount;
139
- } else if (!shouldLongPoll()) {
140
- // slowning down stuff a lot when hidden
141
- // we will need to add a lot of fine tuning here
142
- interval = interval * 4;
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
- pollTimeout = setTimeout(poll, interval);
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-03 00:00:00.000000000 Z
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.3
127
+ rubygems_version: 2.0.14
128
128
  signing_key:
129
129
  specification_version: 4
130
130
  summary: ''