active_publisher 1.3.0.pre0 → 1.3.0.pre1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/active_publisher/async/redis_adapter/consumer.rb +19 -14
- data/lib/active_publisher/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: 610c3fc6b74529fb45b34285b8e0b5c9668f1740
|
4
|
+
data.tar.gz: a7f34b1ec9e70c06a5b7551cf43cb39cb58f0228
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4145544e02e5d17d7e6b5683b77d63c71fd414c8debd499f7dac519399d7922e92573619f8e409f243e506f7c88c5791fe30434dfcbd61e1a00b17ca95bda4a2
|
7
|
+
data.tar.gz: ae4952b6c8f6d54ade4d9a9e36f894cd4416fc413264bb8a6221a7d14d8c8ea52c81a159e856b36ff5cc52bfdb3c1c09574b7298db8e986dc4cdac3b5cad263a
|
@@ -9,28 +9,33 @@ module ActivePublisher
|
|
9
9
|
:timeout_interval => 5, # seconds
|
10
10
|
}
|
11
11
|
|
12
|
-
attr_reader :
|
12
|
+
attr_reader :consumers, :queue, :supervisor
|
13
13
|
|
14
14
|
def initialize(redis_pool)
|
15
15
|
@queue = ::ActivePublisher::Async::RedisAdapter::RedisMultiPopQueue.new(redis_pool, ::ActivePublisher::Async::RedisAdapter::REDIS_LIST_KEY)
|
16
|
-
|
16
|
+
@consumers = {}
|
17
|
+
create_and_supervise_consumers!
|
17
18
|
end
|
18
19
|
|
19
|
-
def
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
consumer
|
26
|
-
|
20
|
+
def create_and_supervise_consumers!
|
21
|
+
::ActivePublisher.configuration.publisher_threads.times do
|
22
|
+
consumer_id = ::SecureRandom.uuid
|
23
|
+
consumers[consumer_id] = ::ActivePublisher::Async::InMemoryAdapter::ConsumerThread.new(queue)
|
24
|
+
|
25
|
+
supervisor_task = ::Concurrent::TimerTask.new(SUPERVISOR_INTERVAL) do
|
26
|
+
consumer = consumers[consumer_id]
|
27
|
+
# This may also be the place to start additional publishers when we are getting backed up ... ?
|
28
|
+
unless consumer.alive?
|
29
|
+
consumer.kill rescue nil
|
30
|
+
consumers[consumer_id] = ::ActivePublisher::Async::InMemoryAdapter::ConsumerThread.new(queue)
|
31
|
+
end
|
32
|
+
|
33
|
+
# Notify the current queue size.
|
34
|
+
::ActiveSupport::Notifications.instrument "redis_async_queue_size.active_publisher", queue.size
|
27
35
|
end
|
28
36
|
|
29
|
-
|
30
|
-
::ActiveSupport::Notifications.instrument "redis_async_queue_size.active_publisher", queue.size
|
37
|
+
supervisor_task.execute
|
31
38
|
end
|
32
|
-
|
33
|
-
supervisor_task.execute
|
34
39
|
end
|
35
40
|
|
36
41
|
def size
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: active_publisher
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.3.0.
|
4
|
+
version: 1.3.0.pre1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Stien
|
@@ -12,7 +12,7 @@ authors:
|
|
12
12
|
autorequire:
|
13
13
|
bindir: exe
|
14
14
|
cert_chain: []
|
15
|
-
date: 2018-03-
|
15
|
+
date: 2018-03-14 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
name: bunny
|