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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA256:
3
- metadata.gz: 205bf97d0f41e320989b1399fcb27607d0a8090c67de4cefa91077b999738244
4
- data.tar.gz: fb7f739ec964c77f51554d14c53afc200d1aa8adce0a5c114189dbe1943424cb
2
+ SHA1:
3
+ metadata.gz: c19b632c04f16f568be2eeeeaf800ee8e1f721a7
4
+ data.tar.gz: b3b5d8d76bb8ef95ba311a7ef6e425dbbf0ba94c
5
5
  SHA512:
6
- metadata.gz: 77f537b065063574df42f2a2926048bed6e69fc2f72608b9be5030d5af3ab78bb1c8c67ed1369911422b7b04a757191d2c5f1c5aeb1b4149518574d185306482
7
- data.tar.gz: 4624d5868cc61dc97b5cbd6acd61e798f6b5c02f567f6baf3279831e79b5c0f1ed6bca90a5e1c586d4ed2bb8eb49ae73350d9d3a80bd3433ede1804a8c82a6d2
6
+ metadata.gz: 6b5fdb514823e21dc486f7ad9d21a673b799fdceb8c5ec67decb6a875dae4bdd96da1121c7608e0927c440739440ac02eea750fb3db8c39047ef35bb621823bf
7
+ data.tar.gz: 04d7c3b2fbd44f160512e9990c63b27a2724cd1dd429941475e7904475215473ae5983402ab0e02c5fb0c8394a1e9f852025394ce601e33768899dca3c919476
data/.travis.yml CHANGED
@@ -3,6 +3,10 @@ rvm:
3
3
  - 2.3
4
4
  - 2.4
5
5
  - jruby-9.1.12.0
6
+ addons:
7
+ apt:
8
+ packages:
9
+ - rabbitmq-server
6
10
  services:
7
11
  - rabbitmq
8
12
  sudo: false
@@ -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) unless current_messages.nil?
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
- ::ActiveSupport::Notifications.instrument "message_published.active_publisher", :message_count => messages.size do
112
- exchange = channel.topic(exchange_name)
113
- messages.each do |message|
114
- fail ActivePublisher::ExchangeMismatchError, "bulk publish messages must match publish_all exchange_name" if message.exchange_name != exchange_name
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.lpush(::ActivePublisher::Async::RedisAdapter::REDIS_LIST_KEY, encoded_messages)
68
+ redis.rpush(::ActivePublisher::Async::RedisAdapter::REDIS_LIST_KEY, encoded_messages)
68
69
  end
69
70
  end
70
71
  end
@@ -32,8 +32,11 @@ module ActivePublisher
32
32
 
33
33
  supervisor_task.execute
34
34
  end
35
- end
36
35
 
36
+ def size
37
+ queue.size
38
+ end
39
+ end
37
40
  end
38
41
  end
39
42
  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.lpush(list_key, encoded_message)
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.lpush(list_key, encoded_messages)
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.pipelined do
77
- number.times do
78
- messages << redis.rpop(list_key)
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
- messages.compact!
86
- messages.map { |message| ::Marshal.load(message.value) }
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
@@ -1,3 +1,3 @@
1
1
  module ActivePublisher
2
- VERSION = "1.2.0.pre"
2
+ VERSION = "1.2.1"
3
3
  end
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.0.pre
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: 2018-01-16 00:00:00.000000000 Z
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: 1.3.1
224
+ version: '0'
225
225
  requirements: []
226
226
  rubyforge_project:
227
- rubygems_version: 2.6.11
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