message_bus 1.0.13 → 1.0.14
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 -1
- data/CHANGELOG +5 -0
- data/README.md +1 -1
- data/lib/message_bus.rb +32 -10
- data/lib/message_bus/redis/reliable_pub_sub.rb +1 -1
- data/lib/message_bus/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6909db1677e03068c2536f5576a123e371f946dd
|
4
|
+
data.tar.gz: a4aab49db0edf4340ca5cd84a9f6c4a75f2928bf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: be441795c69094b47ac1860310ff33e35bb1a61920ed31f93bffd5425a13a505f6ff8d0a04b19779700ed457c263414be5daa6001c349925880958acd966bdd3
|
7
|
+
data.tar.gz: 455e07565586f43d12d89fbe7ee79177aad36973b5f4576d5cdafbebd9f9249b370df3f8023a77575c32e4cc697c4b4a44b501b161a6fcfec14d5021d808c811
|
data/.travis.yml
CHANGED
data/CHANGELOG
CHANGED
@@ -1,3 +1,8 @@
|
|
1
|
+
08-06-2015
|
2
|
+
- Version 1.0.14
|
3
|
+
- Fix: we can not use Thread#kill best keepalive can do is terminate process cleanly
|
4
|
+
- Feature: you can opt-out of keepalive with MessageBus.keepalive_timeout = 0
|
5
|
+
|
1
6
|
08-06-2015
|
2
7
|
- Version 1.0.13
|
3
8
|
- Fix: on global subscribe reconnect replay missed messages
|
data/README.md
CHANGED
data/lib/message_bus.rb
CHANGED
@@ -328,6 +328,17 @@ module MessageBus::Implementation
|
|
328
328
|
end
|
329
329
|
end
|
330
330
|
|
331
|
+
# set to 0 to disable, anything higher and
|
332
|
+
# a keepalive will run every N seconds, if it fails
|
333
|
+
# process is killed
|
334
|
+
def keepalive_interval=(interval)
|
335
|
+
@keepalive_interval = interval
|
336
|
+
end
|
337
|
+
|
338
|
+
def keepalive_interval
|
339
|
+
@keepalive_interval || 60
|
340
|
+
end
|
341
|
+
|
331
342
|
protected
|
332
343
|
|
333
344
|
def global?(channel)
|
@@ -385,9 +396,10 @@ module MessageBus::Implementation
|
|
385
396
|
end
|
386
397
|
end
|
387
398
|
|
388
|
-
|
399
|
+
MIN_KEEPALIVE = 20
|
389
400
|
|
390
401
|
def new_subscriber_thread
|
402
|
+
|
391
403
|
thread = Thread.new do
|
392
404
|
begin
|
393
405
|
global_subscribe_thread unless @destroyed
|
@@ -395,25 +407,36 @@ module MessageBus::Implementation
|
|
395
407
|
MessageBus.logger.warn "Unexpected error in subscriber thread #{e}"
|
396
408
|
end
|
397
409
|
end
|
410
|
+
|
398
411
|
blk = proc do
|
399
412
|
if !@destroyed && thread.alive?
|
400
413
|
publish("/__mb_keepalive__/", Process.pid, user_ids: [-1])
|
401
|
-
if Time.now - (@last_message || Time.now) >
|
402
|
-
MessageBus.logger.warn "Global messages on #{Process.pid} timed out, restarting
|
414
|
+
if (Time.now - (@last_message || Time.now)) > keepalive_interval*2
|
415
|
+
MessageBus.logger.warn "Global messages on #{Process.pid} timed out, restarting process"
|
403
416
|
# No other clean way to remove this thread, its listening on a socket
|
404
417
|
# no data is arriving
|
405
418
|
#
|
406
419
|
# In production we see this kind of situation ... sometimes ... when there is
|
407
420
|
# a VRRP failover, or weird networking condition
|
408
|
-
|
409
|
-
|
410
|
-
|
421
|
+
pid = Process.pid
|
422
|
+
|
423
|
+
# do the best we can to terminate self cleanly
|
424
|
+
fork do
|
425
|
+
Process.kill('TERM', pid)
|
426
|
+
sleep 10
|
427
|
+
Process.kill('KILL', pid)
|
428
|
+
end
|
429
|
+
|
430
|
+
sleep 10
|
431
|
+
Process.kill('KILL', pid)
|
432
|
+
|
411
433
|
else
|
412
|
-
timer.queue(
|
434
|
+
timer.queue(keepalive_interval, &blk) if keepalive_interval > MIN_KEEPALIVE
|
413
435
|
end
|
414
436
|
end
|
415
437
|
end
|
416
|
-
|
438
|
+
|
439
|
+
timer.queue(keepalive_interval, &blk) if keepalive_interval > MIN_KEEPALIVE
|
417
440
|
|
418
441
|
thread
|
419
442
|
end
|
@@ -421,7 +444,7 @@ module MessageBus::Implementation
|
|
421
444
|
def global_subscribe_thread
|
422
445
|
# pretend we just got a message
|
423
446
|
@last_message = Time.now
|
424
|
-
reliable_pub_sub.global_subscribe
|
447
|
+
reliable_pub_sub.global_subscribe do |msg|
|
425
448
|
begin
|
426
449
|
@last_message = Time.now
|
427
450
|
decode_message!(msg)
|
@@ -429,7 +452,6 @@ module MessageBus::Implementation
|
|
429
452
|
|
430
453
|
@mutex.synchronize do
|
431
454
|
raise MessageBus::BusDestroyed if @destroyed
|
432
|
-
@last_message_time = Time.now
|
433
455
|
globals = @subscriptions[nil]
|
434
456
|
locals = @subscriptions[msg.site_id] if msg.site_id
|
435
457
|
|
data/lib/message_bus/version.rb
CHANGED
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: 1.0.
|
4
|
+
version: 1.0.14
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sam Saffron
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-06-
|
11
|
+
date: 2015-06-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rack
|