ruby_rabbitmq_janus 2.6.0.pre.244 → 2.6.0.pre.246
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rrj/rabbit/listener/base.rb +3 -11
- data/lib/rrj/rabbit/listener/from.rb +11 -2
- data/lib/rrj/rabbit/listener/from_admin.rb +10 -2
- data/lib/rrj/rabbit/listener/janus_instance.rb +5 -5
- data/lib/rrj/tools/bin/environment.rb +12 -4
- data/lib/rrj/tools/bin/init.rb +15 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 91b38bd476021288dadfc1a47a4c2226d5690544b9993542944dd1f9f18759c7
|
4
|
+
data.tar.gz: 68afeed194a61a7a0fc43398cf798bc95f59041fad368de7f54cbab9535310fe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a7eade36b3abe79be1d5f56dc19328b86c01fd8b156285819aeaab34e1d3a7dd822fad37ec741face0c5974fe2426ced0d02c9c694e5be399d16a20d9bed6876
|
7
|
+
data.tar.gz: 795ee29c47503a800ab093cf1d51852a897f326066be3ace3c3e9803b6b02b37b848b1a74948bf5b5833ea10fd78207ee839360e77a89a3e23b0a6cca55c8f64
|
@@ -12,7 +12,6 @@ module RubyRabbitmqJanus
|
|
12
12
|
# @param [String] rabbit Information connection to rabbitmq server
|
13
13
|
def initialize(rabbit)
|
14
14
|
super()
|
15
|
-
@responses = []
|
16
15
|
@rabbit = rabbit.channel
|
17
16
|
subscribe_queue
|
18
17
|
rescue
|
@@ -24,7 +23,7 @@ module RubyRabbitmqJanus
|
|
24
23
|
semaphore.wait
|
25
24
|
response = nil
|
26
25
|
lock.synchronize do
|
27
|
-
response =
|
26
|
+
response = responses.shift
|
28
27
|
end
|
29
28
|
yield response.event, response
|
30
29
|
rescue => exception
|
@@ -34,6 +33,8 @@ module RubyRabbitmqJanus
|
|
34
33
|
|
35
34
|
private
|
36
35
|
|
36
|
+
attr_accessor :rabbit, :responses
|
37
|
+
|
37
38
|
def binding
|
38
39
|
@rabbit.direct('amq.direct')
|
39
40
|
end
|
@@ -48,15 +49,6 @@ module RubyRabbitmqJanus
|
|
48
49
|
Tools::Log.instance.info "[X] Message reading with ID #{message_id}"
|
49
50
|
end
|
50
51
|
|
51
|
-
# Sending an signal when an response is reading in queue
|
52
|
-
def synchronize_response(info, payload)
|
53
|
-
lock.synchronize do
|
54
|
-
@responses.push(Janus::Responses::Event.new(JSON.parse(payload)))
|
55
|
-
end
|
56
|
-
@rabbit.acknowledge(info.delivery_tag, false)
|
57
|
-
semaphore.signal
|
58
|
-
end
|
59
|
-
|
60
52
|
def info_subscribe(info, prop, payload)
|
61
53
|
Tools::Log.instance.debug info
|
62
54
|
Tools::Log.instance.info \
|
@@ -15,8 +15,8 @@ module RubyRabbitmqJanus
|
|
15
15
|
private
|
16
16
|
|
17
17
|
def subscribe_queue
|
18
|
-
reply =
|
19
|
-
|
18
|
+
reply = rabbit.queue(Tools::Config.instance.queue_from)
|
19
|
+
rabbit.prefetch(1)
|
20
20
|
reply.bind(binding).subscribe(opts_subs) do |info, prop, payload|
|
21
21
|
info_subscribe(info, prop, payload)
|
22
22
|
synchronize_response(info, payload)
|
@@ -25,6 +25,15 @@ module RubyRabbitmqJanus
|
|
25
25
|
raise RubyRabbitmqJanus::Errors::Rabbit::Listener::From::ListenEvents,
|
26
26
|
exception
|
27
27
|
end
|
28
|
+
|
29
|
+
def synchronize_response(info, payload)
|
30
|
+
lock.synchronize do
|
31
|
+
response = Janus::Responses::Event.new(JSON.parse(payload))
|
32
|
+
responses.push(response)
|
33
|
+
end
|
34
|
+
rabbit.acknowledge(info.delivery_tag, false)
|
35
|
+
semaphore.signal
|
36
|
+
end
|
28
37
|
end
|
29
38
|
end
|
30
39
|
end
|
@@ -10,8 +10,8 @@ module RubyRabbitmqJanus
|
|
10
10
|
private
|
11
11
|
|
12
12
|
def subscribe_queue
|
13
|
-
reply =
|
14
|
-
|
13
|
+
reply = rabbit.queue(Tools::Config.instance.queue_admin_from)
|
14
|
+
rabbit.prefetch(1)
|
15
15
|
reply.bind(binding).subscribe(opts_subs) do |info, prop, payload|
|
16
16
|
info_subscribe(info, prop, payload)
|
17
17
|
synchronize_response(info, payload)
|
@@ -20,6 +20,14 @@ module RubyRabbitmqJanus
|
|
20
20
|
raise RubyRabbitmqJanus::Errors::Rabbit::Listener::From::ListenEvents,
|
21
21
|
exception
|
22
22
|
end
|
23
|
+
|
24
|
+
def synchronize_response(info, payload)
|
25
|
+
lock.synchronize do
|
26
|
+
@responses.push(Janus::Responses::Admin.new(JSON.parse(payload)))
|
27
|
+
end
|
28
|
+
rabbit.acknowledge(info.delivery_tag, false)
|
29
|
+
semaphore.signal
|
30
|
+
end
|
23
31
|
end
|
24
32
|
end
|
25
33
|
end
|
@@ -8,12 +8,12 @@ module RubyRabbitmqJanus
|
|
8
8
|
# :reek:InstanceVariableAssumption
|
9
9
|
|
10
10
|
# Listener to admin queue
|
11
|
-
class JanusInstance <
|
11
|
+
class JanusInstance < Base
|
12
12
|
private
|
13
13
|
|
14
14
|
def subscribe_queue
|
15
|
-
reply =
|
16
|
-
|
15
|
+
reply = rabbit.queue(Tools::Config.instance.queue_janus_instance)
|
16
|
+
rabbit.prefetch(1)
|
17
17
|
reply.bind(binding).subscribe(opts_subs) do |info, prop, payload|
|
18
18
|
info_subscribe(info, prop, payload)
|
19
19
|
synchronize_response(info, payload)
|
@@ -27,9 +27,9 @@ module RubyRabbitmqJanus
|
|
27
27
|
def synchronize_response(info, payload)
|
28
28
|
lock.synchronize do
|
29
29
|
response = Janus::Responses::JanusInstance.new(JSON.parse(payload))
|
30
|
-
|
30
|
+
responses.push(response)
|
31
31
|
end
|
32
|
-
|
32
|
+
rabbit.acknowledge(info.delivery_tag, false)
|
33
33
|
semaphore.signal
|
34
34
|
end
|
35
35
|
end
|
@@ -2,10 +2,18 @@
|
|
2
2
|
|
3
3
|
# Load environment variables for execute correctly `Binary` class
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
5
|
+
def blank?(value)
|
6
|
+
value.eql?('') || value.nil?
|
7
|
+
end
|
8
|
+
|
9
|
+
def check_variable(name)
|
10
|
+
blank?(ENV[name]) ? raise(NameError) : ENV[name]
|
11
|
+
end
|
12
|
+
|
13
|
+
ENVIRONMENT = check_variable('RAILS_ENV')
|
14
|
+
ORM = check_variable('ORM')
|
15
|
+
LISTENER_PATH = check_variable('LISTENER_PATH')
|
16
|
+
PROGRAM = check_variable('PROGRAM_NAME')
|
9
17
|
|
10
18
|
@verbose = false
|
11
19
|
@logger_class = true
|
data/lib/rrj/tools/bin/init.rb
CHANGED
@@ -21,7 +21,21 @@ Log.info RubyRabbitmqJanus::BANNER
|
|
21
21
|
require File.join(File.dirname(__FILE__), '..', '..', 'binary')
|
22
22
|
|
23
23
|
begin
|
24
|
+
Log.info 'Load events public queue classes'
|
24
25
|
bin = RubyRabbitmqJanus::Binary.new
|
26
|
+
Log.info "Load file : #{File.join(Dir.pwd, LISTENER_PATH)}"
|
27
|
+
require File.join(Dir.pwd, LISTENER_PATH)
|
28
|
+
|
29
|
+
Log.info 'Listen public queue in thread'
|
30
|
+
actions = RubyRabbitmqJanus::ActionEvents.new.actions
|
31
|
+
RubyRabbitmqJanus::Janus::Concurrencies::Event.instance.run(&actions)
|
32
|
+
rescue => exception
|
33
|
+
Log.fatal '!! Fail to start RRJ Thread listen public queue !!'
|
34
|
+
Log.fatal exception
|
35
|
+
exit 1
|
36
|
+
end
|
37
|
+
|
38
|
+
begin
|
25
39
|
Log.info \
|
26
40
|
'Prepare to listen events in queue : ' + \
|
27
41
|
RubyRabbitmqJanus::Tools::Config.instance.queue_janus_instance
|
@@ -37,7 +51,7 @@ begin
|
|
37
51
|
end
|
38
52
|
end
|
39
53
|
rescue => exception
|
40
|
-
Log.fatal '!! Fail to start RRJ
|
54
|
+
Log.fatal '!! Fail to start RRJ Thread Janus Instance management !!'
|
41
55
|
Log.fatal exception
|
42
56
|
exit 1
|
43
57
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ruby_rabbitmq_janus
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.6.0.pre.
|
4
|
+
version: 2.6.0.pre.246
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- VAILLANT Jeremy
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2019-08-
|
11
|
+
date: 2019-08-22 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|