active_publisher 1.2.5 → 1.2.6
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 736d696175390213664c2c01397673dff014a7aea213b64c99851a3d962aa3d2
|
|
4
|
+
data.tar.gz: 2f7efd868a202eec1513322d638023b00aa16c5e3f74c14a919484c06cb75289
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: a2e4c032c91c55dcffd522da05251167007aca709ccfb62f3bd4bff9b20957426109c92bde1b526a40f10996ae93c07628a9d00b31b0ebaf220e3496a0404cf3
|
|
7
|
+
data.tar.gz: 52fcbde823b44976d7a8478ebb13d420fb9bd261675d9462372e8edc11cd01aa7b8705ccd39c44a278c9bdafc48fd9a546495a577ed9c5c9f85d61b6b51ae18e
|
|
@@ -2,7 +2,7 @@ module ActivePublisher
|
|
|
2
2
|
module Async
|
|
3
3
|
module InMemoryAdapter
|
|
4
4
|
class ConsumerThread
|
|
5
|
-
attr_reader :channel, :thread, :queue, :sampled_queue_size, :last_tick_at
|
|
5
|
+
attr_reader :channel, :flush_max, :thread, :queue, :sampled_queue_size, :last_tick_at
|
|
6
6
|
|
|
7
7
|
if ::RUBY_PLATFORM == "java"
|
|
8
8
|
CHANNEL_CLOSED_ERRORS = [::MarchHare::ChannelAlreadyClosed]
|
|
@@ -27,6 +27,7 @@ module ActivePublisher
|
|
|
27
27
|
def initialize(listen_queue)
|
|
28
28
|
@queue = listen_queue
|
|
29
29
|
@sampled_queue_size = queue.size
|
|
30
|
+
@flush_max = ::ActivePublisher.configuration.messages_per_batch
|
|
30
31
|
|
|
31
32
|
update_last_tick_at
|
|
32
33
|
start_thread
|
|
@@ -96,7 +97,7 @@ module ActivePublisher
|
|
|
96
97
|
loop do
|
|
97
98
|
# Sample the queue size so we don't shutdown when messages are in flight.
|
|
98
99
|
@sampled_queue_size = queue.size
|
|
99
|
-
current_messages = queue.pop_up_to(
|
|
100
|
+
current_messages = queue.pop_up_to(flush_max, :timeout => 0.1)
|
|
100
101
|
update_last_tick_at
|
|
101
102
|
# If the queue is empty, we should continue to update to "last_tick_at" time.
|
|
102
103
|
next if current_messages.nil?
|
|
@@ -19,7 +19,7 @@ module ActivePublisher
|
|
|
19
19
|
}
|
|
20
20
|
include ::ActivePublisher::Logging
|
|
21
21
|
|
|
22
|
-
attr_reader :async_queue, :redis_pool, :queue
|
|
22
|
+
attr_reader :async_queue, :flush_max, :flush_min, :redis_pool, :queue
|
|
23
23
|
|
|
24
24
|
def initialize(new_redis_pool)
|
|
25
25
|
logger.info "Starting redis publisher adapter"
|
|
@@ -27,6 +27,8 @@ module ActivePublisher
|
|
|
27
27
|
@redis_pool = new_redis_pool
|
|
28
28
|
@async_queue = ::ActivePublisher::Async::RedisAdapter::Consumer.new(redis_pool)
|
|
29
29
|
@queue = ::MultiOpQueue::Queue.new
|
|
30
|
+
@flush_max = ::ActivePublisher.configuration.messages_per_batch
|
|
31
|
+
@flush_min = @flush_max / 2
|
|
30
32
|
|
|
31
33
|
supervisor_task = ::Concurrent::TimerTask.new(SUPERVISOR_INTERVAL) do
|
|
32
34
|
queue_size = queue.size
|
|
@@ -41,7 +43,7 @@ module ActivePublisher
|
|
|
41
43
|
def publish(route, payload, exchange_name, options = {})
|
|
42
44
|
message = ::ActivePublisher::Message.new(route, payload, exchange_name, options)
|
|
43
45
|
queue << ::Marshal.dump(message)
|
|
44
|
-
flush_queue! if queue.size >=
|
|
46
|
+
flush_queue! if queue.size >= flush_min || options[:flush_queue]
|
|
45
47
|
|
|
46
48
|
nil
|
|
47
49
|
end
|
|
@@ -58,7 +60,7 @@ module ActivePublisher
|
|
|
58
60
|
|
|
59
61
|
def flush_queue!
|
|
60
62
|
return if queue.empty?
|
|
61
|
-
encoded_messages = queue.pop_up_to(
|
|
63
|
+
encoded_messages = queue.pop_up_to(flush_max, :timeout => 0.001)
|
|
62
64
|
|
|
63
65
|
return if encoded_messages.nil?
|
|
64
66
|
return unless encoded_messages.respond_to?(:each)
|
|
@@ -8,6 +8,7 @@ module ActivePublisher
|
|
|
8
8
|
:host,
|
|
9
9
|
:hosts,
|
|
10
10
|
:max_async_publisher_lag_time,
|
|
11
|
+
:messages_per_batch,
|
|
11
12
|
:network_recovery_interval,
|
|
12
13
|
:password,
|
|
13
14
|
:port,
|
|
@@ -36,6 +37,7 @@ module ActivePublisher
|
|
|
36
37
|
:host => "localhost",
|
|
37
38
|
:hosts => [],
|
|
38
39
|
:password => "guest",
|
|
40
|
+
:messages_per_batch => 25,
|
|
39
41
|
:max_async_publisher_lag_time => 10,
|
|
40
42
|
:network_recovery_interval => NETWORK_RECOVERY_INTERVAL,
|
|
41
43
|
:port => 5672,
|
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.2.
|
|
4
|
+
version: 1.2.6
|
|
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:
|
|
15
|
+
date: 2021-09-29 00:00:00.000000000 Z
|
|
16
16
|
dependencies:
|
|
17
17
|
- !ruby/object:Gem::Dependency
|
|
18
18
|
name: bunny
|
|
@@ -223,7 +223,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
223
223
|
- !ruby/object:Gem::Version
|
|
224
224
|
version: '0'
|
|
225
225
|
requirements: []
|
|
226
|
-
|
|
226
|
+
rubyforge_project:
|
|
227
|
+
rubygems_version: 2.7.6
|
|
227
228
|
signing_key:
|
|
228
229
|
specification_version: 4
|
|
229
230
|
summary: Aims to make publishing work across MRI and jRuby painless and add some nice
|