active_publisher 1.2.0.pre-java → 1.2.1-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.travis.yml +4 -0
- data/lib/active_publisher.rb +2 -2
- data/lib/active_publisher/async/in_memory_adapter/consumer_thread.rb +6 -7
- data/lib/active_publisher/async/redis_adapter.rb +2 -1
- data/lib/active_publisher/async/redis_adapter/consumer.rb +4 -1
- data/lib/active_publisher/async/redis_adapter/redis_multi_pop_queue.rb +24 -9
- data/lib/active_publisher/version.rb +1 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: c19b632c04f16f568be2eeeeaf800ee8e1f721a7
|
4
|
+
data.tar.gz: b3b5d8d76bb8ef95ba311a7ef6e425dbbf0ba94c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6b5fdb514823e21dc486f7ad9d21a673b799fdceb8c5ec67decb6a875dae4bdd96da1121c7608e0927c440739440ac02eea750fb3db8c39047ef35bb621823bf
|
7
|
+
data.tar.gz: 04d7c3b2fbd44f160512e9990c63b27a2724cd1dd429941475e7904475215473ae5983402ab0e02c5fb0c8394a1e9f852025394ce601e33768899dca3c919476
|
data/.travis.yml
CHANGED
data/lib/active_publisher.rb
CHANGED
@@ -35,7 +35,7 @@ module ActivePublisher
|
|
35
35
|
# @param [Hash] options hash to set message parameters (e.g. headers)
|
36
36
|
def self.publish(route, payload, exchange_name, options = {})
|
37
37
|
with_exchange(exchange_name) do |exchange|
|
38
|
-
::ActiveSupport::Notifications.instrument "message_published.active_publisher" do
|
38
|
+
::ActiveSupport::Notifications.instrument "message_published.active_publisher", :route => route do
|
39
39
|
exchange.publish(payload, publishing_options(route, options))
|
40
40
|
end
|
41
41
|
end
|
@@ -51,7 +51,7 @@ module ActivePublisher
|
|
51
51
|
fail ActivePublisher::ExchangeMismatchError, "bulk publish messages must match publish_all exchange_name" if message.exchange_name != exchange_name
|
52
52
|
|
53
53
|
begin
|
54
|
-
::ActiveSupport::Notifications.instrument "message_published.active_publisher" do
|
54
|
+
::ActiveSupport::Notifications.instrument "message_published.active_publisher", :route => message.route do
|
55
55
|
exchange.publish(message.payload, publishing_options(message.route, message.options || {}))
|
56
56
|
end
|
57
57
|
rescue
|
@@ -101,23 +101,22 @@ module ActivePublisher
|
|
101
101
|
raise unknown_error
|
102
102
|
ensure
|
103
103
|
# Always requeue anything that gets stuck.
|
104
|
-
queue.concat(current_messages)
|
104
|
+
queue.concat(current_messages) if current_messages && !current_messages.empty?
|
105
105
|
end
|
106
106
|
end
|
107
107
|
end
|
108
108
|
end
|
109
109
|
|
110
110
|
def publish_all(channel, exchange_name, messages)
|
111
|
-
|
112
|
-
|
113
|
-
messages.
|
114
|
-
|
115
|
-
|
111
|
+
exchange = channel.topic(exchange_name)
|
112
|
+
messages.each do |message|
|
113
|
+
fail ::ActivePublisher::ExchangeMismatchError, "bulk publish messages must match publish_all exchange_name" if message.exchange_name != exchange_name
|
114
|
+
::ActiveSupport::Notifications.instrument "message_published.active_publisher", :route => message.route, :message_count => 1 do
|
116
115
|
options = ::ActivePublisher.publishing_options(message.route, message.options || {})
|
117
116
|
exchange.publish(message.payload, options)
|
118
117
|
end
|
119
|
-
wait_for_confirms(channel)
|
120
118
|
end
|
119
|
+
wait_for_confirms(channel)
|
121
120
|
end
|
122
121
|
|
123
122
|
def wait_for_confirms(channel)
|
@@ -1,3 +1,4 @@
|
|
1
|
+
require "active_publisher"
|
1
2
|
require "active_publisher/message"
|
2
3
|
require "active_publisher/async/redis_adapter/consumer"
|
3
4
|
require "multi_op_queue"
|
@@ -64,7 +65,7 @@ module ActivePublisher
|
|
64
65
|
return unless encoded_messages.size > 0
|
65
66
|
|
66
67
|
redis_pool.with do |redis|
|
67
|
-
redis.
|
68
|
+
redis.rpush(::ActivePublisher::Async::RedisAdapter::REDIS_LIST_KEY, encoded_messages)
|
68
69
|
end
|
69
70
|
end
|
70
71
|
end
|
@@ -13,13 +13,14 @@ module ActivePublisher
|
|
13
13
|
encoded_message = ::Marshal.dump(message)
|
14
14
|
|
15
15
|
redis_pool.with do |redis|
|
16
|
-
redis.
|
16
|
+
redis.rpush(list_key, encoded_message)
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
20
|
def concat(*messages)
|
21
21
|
messages = messages.flatten
|
22
22
|
messages.compact!
|
23
|
+
return if messages.empty?
|
23
24
|
|
24
25
|
encoded_messages = []
|
25
26
|
messages.each do |message|
|
@@ -27,7 +28,7 @@ module ActivePublisher
|
|
27
28
|
end
|
28
29
|
|
29
30
|
redis_pool.with do |redis|
|
30
|
-
redis.
|
31
|
+
redis.rpush(list_key, encoded_messages)
|
31
32
|
end
|
32
33
|
end
|
33
34
|
|
@@ -70,20 +71,34 @@ module ActivePublisher
|
|
70
71
|
end
|
71
72
|
|
72
73
|
def shift(number)
|
73
|
-
messages = []
|
74
74
|
number = [number, size].min
|
75
|
+
return [] if number <= 0
|
76
|
+
|
77
|
+
messages = []
|
78
|
+
multi_response = []
|
75
79
|
redis_pool.with do |redis|
|
76
|
-
redis.
|
77
|
-
|
78
|
-
|
79
|
-
end
|
80
|
+
multi_response = redis.multi do
|
81
|
+
redis.lrange(list_key, 0, number - 1)
|
82
|
+
redis.ltrim(list_key, number, -1)
|
80
83
|
end
|
81
84
|
end
|
82
85
|
|
86
|
+
messages = multi_response.first
|
87
|
+
success = multi_response.last
|
88
|
+
return [] if multi_response.size != 2 || success.nil?
|
89
|
+
return [] unless success =~ /ok/i
|
90
|
+
|
83
91
|
messages = [] if messages.nil?
|
84
92
|
messages = [messages] unless messages.respond_to?(:each)
|
85
|
-
|
86
|
-
|
93
|
+
|
94
|
+
shifted_messages = []
|
95
|
+
messages.each do |message|
|
96
|
+
next if message.nil?
|
97
|
+
|
98
|
+
shifted_messages << ::Marshal.load(message)
|
99
|
+
end
|
100
|
+
|
101
|
+
shifted_messages
|
87
102
|
end
|
88
103
|
|
89
104
|
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.2.
|
4
|
+
version: 1.2.1
|
5
5
|
platform: java
|
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: 2020-04-17 00:00:00.000000000 Z
|
16
16
|
dependencies:
|
17
17
|
- !ruby/object:Gem::Dependency
|
18
18
|
requirement: !ruby/object:Gem::Requirement
|
@@ -219,12 +219,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
219
219
|
version: '0'
|
220
220
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
221
221
|
requirements:
|
222
|
-
- - "
|
222
|
+
- - ">="
|
223
223
|
- !ruby/object:Gem::Version
|
224
|
-
version:
|
224
|
+
version: '0'
|
225
225
|
requirements: []
|
226
226
|
rubyforge_project:
|
227
|
-
rubygems_version: 2.6.
|
227
|
+
rubygems_version: 2.6.14.1
|
228
228
|
signing_key:
|
229
229
|
specification_version: 4
|
230
230
|
summary: Aims to make publishing work across MRI and jRuby painless and add some nice
|