promiscuous 0.32.0 → 0.33.0
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/promiscuous.rb +10 -0
- data/lib/promiscuous/amqp.rb +1 -0
- data/lib/promiscuous/amqp/bunny.rb +0 -1
- data/lib/promiscuous/amqp/ruby_amqp.rb +0 -3
- data/lib/promiscuous/cli.rb +2 -2
- data/lib/promiscuous/config.rb +1 -2
- data/lib/promiscuous/redis.rb +6 -0
- data/lib/promiscuous/subscriber.rb +1 -1
- data/lib/promiscuous/subscriber/amqp.rb +2 -4
- data/lib/promiscuous/subscriber/dummy.rb +19 -0
- data/lib/promiscuous/subscriber/model.rb +1 -0
- data/lib/promiscuous/subscriber/worker.rb +8 -4
- data/lib/promiscuous/subscriber/worker/pump.rb +2 -1
- data/lib/promiscuous/version.rb +1 -1
- metadata +8 -7
data/lib/promiscuous.rb
CHANGED
@@ -26,6 +26,16 @@ module Promiscuous
|
|
26
26
|
desc.each { |klass| klass.setup_class_binding }
|
27
27
|
end
|
28
28
|
|
29
|
+
def connect
|
30
|
+
AMQP.connect
|
31
|
+
Redis.connect
|
32
|
+
end
|
33
|
+
|
34
|
+
def disconnect
|
35
|
+
AMQP.disconnect
|
36
|
+
Redis.disconnect
|
37
|
+
end
|
38
|
+
|
29
39
|
def healthy?
|
30
40
|
AMQP.ensure_connected
|
31
41
|
Redis.ensure_connected
|
data/lib/promiscuous/amqp.rb
CHANGED
@@ -16,7 +16,6 @@ module Promiscuous::AMQP:: Bunny
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def self.publish(options={})
|
19
|
-
Promiscuous.debug "[publish] (#{options[:exchange_name]}) #{options[:key]} -> #{options[:payload]}"
|
20
19
|
exchange(options[:exchange_name]).
|
21
20
|
publish(options[:payload], :key => options[:key], :persistent => true)
|
22
21
|
end
|
@@ -79,9 +79,6 @@ module Promiscuous::AMQP::RubyAMQP
|
|
79
79
|
end
|
80
80
|
|
81
81
|
def self.publish(options={})
|
82
|
-
info_msg = "(#{options[:exchange_name]}) #{options[:key]} -> #{options[:payload]}"
|
83
|
-
Promiscuous.debug "[publish] #{info_msg}"
|
84
|
-
|
85
82
|
EM.next_tick do
|
86
83
|
exchange(options[:exchange_name]).
|
87
84
|
publish(options[:payload], :routing_key => options[:key], :persistent => true)
|
data/lib/promiscuous/cli.rb
CHANGED
data/lib/promiscuous/config.rb
CHANGED
data/lib/promiscuous/redis.rb
CHANGED
@@ -4,9 +4,15 @@ module Promiscuous::Redis
|
|
4
4
|
mattr_accessor :master
|
5
5
|
|
6
6
|
def self.connect
|
7
|
+
disconnect if self.master
|
7
8
|
self.master = new_connection
|
8
9
|
end
|
9
10
|
|
11
|
+
def self.disconnect
|
12
|
+
self.master.client.disconnect
|
13
|
+
self.master = nil
|
14
|
+
end
|
15
|
+
|
10
16
|
def self.new_connection
|
11
17
|
return Null.new if Promiscuous::Config.backend == :null
|
12
18
|
|
@@ -1,7 +1,7 @@
|
|
1
1
|
module Promiscuous::Subscriber
|
2
2
|
extend Promiscuous::Autoload
|
3
3
|
autoload :ActiveRecord, :AMQP, :Attributes, :Base, :Class, :Envelope, :Error,
|
4
|
-
:Lint, :Model, :Mongoid, :Polymorphic, :Upsert, :Observer, :Worker
|
4
|
+
:Lint, :Model, :Mongoid, :Polymorphic, :Upsert, :Observer, :Worker, :Dummy
|
5
5
|
|
6
6
|
def self.lint(*args)
|
7
7
|
Lint.lint(*args)
|
@@ -7,10 +7,8 @@ module Promiscuous::Subscriber::AMQP
|
|
7
7
|
|
8
8
|
def self.subscriber_from(payload)
|
9
9
|
if key = payload.is_a?(Hash) ? payload['__amqp__'] : nil
|
10
|
-
|
11
|
-
|
12
|
-
end
|
13
|
-
self.subscribers[key]
|
10
|
+
sub = self.subscribers[key]
|
11
|
+
sub ||= Promiscuous::Subscriber::Dummy
|
14
12
|
end
|
15
13
|
end
|
16
14
|
|
@@ -0,0 +1,19 @@
|
|
1
|
+
class Promiscuous::Subscriber::Dummy < Promiscuous::Subscriber::Base
|
2
|
+
include Promiscuous::Subscriber::Class
|
3
|
+
include Promiscuous::Subscriber::Attributes
|
4
|
+
include Promiscuous::Subscriber::AMQP
|
5
|
+
include Promiscuous::Subscriber::Envelope
|
6
|
+
include Promiscuous::Subscriber::Model
|
7
|
+
|
8
|
+
class DummyInstance
|
9
|
+
attr_accessor :id
|
10
|
+
end
|
11
|
+
|
12
|
+
def klass
|
13
|
+
DummyInstance
|
14
|
+
end
|
15
|
+
|
16
|
+
def operation
|
17
|
+
:dummy
|
18
|
+
end
|
19
|
+
end
|
@@ -29,10 +29,14 @@ class Promiscuous::Subscriber::Worker
|
|
29
29
|
def stop
|
30
30
|
return if self.stopped
|
31
31
|
self.pump.stop
|
32
|
-
self.message_synchronizer
|
33
|
-
|
34
|
-
|
35
|
-
|
32
|
+
if self.message_synchronizer
|
33
|
+
self.message_synchronizer.stop rescue Celluloid::Task::TerminatedError
|
34
|
+
self.message_synchronizer = nil
|
35
|
+
end
|
36
|
+
if self.runners
|
37
|
+
self.runners.terminate
|
38
|
+
self.runners = nil
|
39
|
+
end
|
36
40
|
self.stopped = true
|
37
41
|
# TODO wait for the runners to finish
|
38
42
|
end
|
@@ -37,7 +37,8 @@ class Promiscuous::Subscriber::Worker::Pump
|
|
37
37
|
exchange_name += ".#{worker.options[:personality]}"
|
38
38
|
end
|
39
39
|
|
40
|
-
|
40
|
+
# We need to subscribe to everything to keep up with the version tracking
|
41
|
+
bindings = ['*']
|
41
42
|
{:exchange_name => exchange_name, :queue_name => queue_name, :bindings => bindings}
|
42
43
|
end
|
43
44
|
end
|
data/lib/promiscuous/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: promiscuous
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.33.0
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -182,8 +182,8 @@ extensions: []
|
|
182
182
|
extra_rdoc_files: []
|
183
183
|
files:
|
184
184
|
- lib/promiscuous/amqp/null.rb
|
185
|
-
- lib/promiscuous/amqp/bunny.rb
|
186
185
|
- lib/promiscuous/amqp/ruby_amqp.rb
|
186
|
+
- lib/promiscuous/amqp/bunny.rb
|
187
187
|
- lib/promiscuous/common/lint/base.rb
|
188
188
|
- lib/promiscuous/common/class_helpers.rb
|
189
189
|
- lib/promiscuous/common/options.rb
|
@@ -216,39 +216,40 @@ files:
|
|
216
216
|
- lib/promiscuous/subscriber/lint/attributes.rb
|
217
217
|
- lib/promiscuous/subscriber/mongoid/embedded_many.rb
|
218
218
|
- lib/promiscuous/subscriber/mongoid/embedded.rb
|
219
|
-
- lib/promiscuous/subscriber/worker/pump.rb
|
220
219
|
- lib/promiscuous/subscriber/worker/runner.rb
|
221
220
|
- lib/promiscuous/subscriber/worker/message_synchronizer.rb
|
221
|
+
- lib/promiscuous/subscriber/worker/pump.rb
|
222
222
|
- lib/promiscuous/subscriber/worker/message.rb
|
223
223
|
- lib/promiscuous/subscriber/active_record.rb
|
224
224
|
- lib/promiscuous/subscriber/envelope.rb
|
225
225
|
- lib/promiscuous/subscriber/upsert.rb
|
226
226
|
- lib/promiscuous/subscriber/polymorphic.rb
|
227
|
-
- lib/promiscuous/subscriber/amqp.rb
|
228
227
|
- lib/promiscuous/subscriber/attributes.rb
|
229
228
|
- lib/promiscuous/subscriber/base.rb
|
230
229
|
- lib/promiscuous/subscriber/class.rb
|
231
230
|
- lib/promiscuous/subscriber/lint.rb
|
232
231
|
- lib/promiscuous/subscriber/mongoid.rb
|
233
232
|
- lib/promiscuous/subscriber/observer.rb
|
234
|
-
- lib/promiscuous/subscriber/worker.rb
|
235
233
|
- lib/promiscuous/subscriber/model.rb
|
234
|
+
- lib/promiscuous/subscriber/amqp.rb
|
235
|
+
- lib/promiscuous/subscriber/dummy.rb
|
236
|
+
- lib/promiscuous/subscriber/worker.rb
|
236
237
|
- lib/promiscuous/error/subscriber.rb
|
237
238
|
- lib/promiscuous/error/publisher.rb
|
238
239
|
- lib/promiscuous/error/connection.rb
|
239
240
|
- lib/promiscuous/observer.rb
|
240
241
|
- lib/promiscuous/ephemeral.rb
|
241
242
|
- lib/promiscuous/autoload.rb
|
242
|
-
- lib/promiscuous/subscriber.rb
|
243
243
|
- lib/promiscuous/error.rb
|
244
244
|
- lib/promiscuous/loader.rb
|
245
245
|
- lib/promiscuous/railtie.rb
|
246
246
|
- lib/promiscuous/common.rb
|
247
247
|
- lib/promiscuous/publisher.rb
|
248
248
|
- lib/promiscuous/worker.rb
|
249
|
-
- lib/promiscuous/config.rb
|
250
249
|
- lib/promiscuous/amqp.rb
|
250
|
+
- lib/promiscuous/subscriber.rb
|
251
251
|
- lib/promiscuous/redis.rb
|
252
|
+
- lib/promiscuous/config.rb
|
252
253
|
- lib/promiscuous/cli.rb
|
253
254
|
- lib/promiscuous/version.rb
|
254
255
|
- lib/promiscuous.rb
|