ruby_rabbitmq_janus 2.5.1 → 2.6.0.pre.226
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 +4 -4
- data/README.md +1 -1
- data/bin/ruby_rabbitmq_janus +67 -0
- data/config/default.md +3 -0
- data/config/default.yml +6 -0
- data/lib/rrj/binary.rb +56 -0
- data/lib/rrj/errors/rabbit/base_event.rb +21 -0
- data/lib/rrj/errors/rabbit/listener/base.rb +29 -0
- data/lib/rrj/errors/rabbit/listener/from.rb +17 -0
- data/lib/rrj/errors/rabbit/listener/from_admin.rb +17 -0
- data/lib/rrj/errors/rabbit/listener/janus_instance.rb +17 -0
- data/lib/rrj/errors/rabbit/publisher/admin.rb +32 -0
- data/lib/rrj/errors/rabbit/publisher/base.rb +31 -0
- data/lib/rrj/errors/rabbit/publisher/exclusive.rb +33 -0
- data/lib/rrj/errors/rabbit/publisher/janus_instance.rb +23 -0
- data/lib/rrj/errors/rabbit/publisher/keepalive.rb +17 -0
- data/lib/rrj/errors/rabbit/publisher/non_exclusive.rb +33 -0
- data/lib/rrj/errors/rabbit/rabbit.rb +12 -6
- data/lib/rrj/info.rb +6 -5
- data/lib/rrj/init.rb +2 -2
- data/lib/rrj/janus/messages/message.rb +1 -1
- data/lib/rrj/janus/processus/event.rb +1 -1
- data/lib/rrj/janus/processus/keepalive/keepalive_thread.rb +3 -2
- data/lib/rrj/janus/responses/janus_instance.rb +28 -0
- data/lib/rrj/janus/responses/response.rb +1 -1
- data/lib/rrj/janus/transactions/admin.rb +1 -1
- data/lib/rrj/janus/transactions/handle.rb +1 -1
- data/lib/rrj/janus/transactions/transaction.rb +2 -2
- data/lib/rrj/models/concerns/janus_instance_callbacks.rb +9 -5
- data/lib/rrj/models/concerns/janus_instance_methods.rb +12 -0
- data/lib/rrj/rabbit/base_event.rb +47 -0
- data/lib/rrj/rabbit/connect.rb +12 -12
- data/lib/rrj/rabbit/{publish/listener.rb → listener/base.rb} +16 -18
- data/lib/rrj/rabbit/listener/from.rb +30 -0
- data/lib/rrj/rabbit/{publish/listener_admin.rb → listener/from_admin.rb} +6 -4
- data/lib/rrj/rabbit/listener/janus_instance.rb +36 -0
- data/lib/rrj/rabbit/{publish/publisher_admin.rb → publisher/admin.rb} +5 -10
- data/lib/rrj/rabbit/{publish/publisher.rb → publisher/base.rb} +10 -8
- data/lib/rrj/rabbit/{publish → publisher}/exclusive.rb +3 -3
- data/lib/rrj/rabbit/publisher/janus_instance.rb +27 -0
- data/lib/rrj/rabbit/{publish → publisher}/keepalive.rb +4 -2
- data/lib/rrj/rabbit/{publish → publisher}/non_exclusive.rb +3 -7
- data/lib/rrj/rabbit/rabbit.rb +1 -1
- data/lib/rrj/tools/gem/cluster.rb +0 -17
- data/lib/rrj/tools/gem/config.rb +9 -0
- data/lib/rrj/tools/gem/log.rb +3 -4
- data/lib/rrj/tools/gem/option.rb +2 -12
- data/lib/rrj/tools/replaces/admin.rb +4 -4
- data/lib/rrj/tools/replaces/handle.rb +6 -6
- data/lib/rrj/tools/replaces/replace.rb +6 -6
- data/lib/rrj/tools/replaces/session.rb +4 -4
- data/spec/factories/janus_instance.rb +1 -1
- data/spec/request/admin/request_allow_token_spec.rb +1 -0
- data/spec/request/admin/request_disallow_token_spec.rb +1 -0
- data/spec/request/admin/request_handle_info_spec.rb +1 -0
- data/spec/request/admin/request_list_handles_spec.rb +1 -0
- data/spec/request/admin/request_list_sessions_spec.rb +1 -0
- data/spec/request/admin/request_start_pcap_spec.rb +1 -0
- data/spec/request/admin/request_start_text2pcap_spec.rb +1 -0
- data/spec/request/admin/request_stop_pcap_spec.rb +1 -0
- data/spec/request/admin/request_stop_text2pcap_spec.rb +1 -0
- data/spec/request/base/request_attach_spec.rb +1 -1
- data/spec/request/base/request_create_spec.rb +2 -2
- data/spec/request/base/request_destroy_spec.rb +1 -1
- data/spec/request/base/request_detach_spec.rb +1 -1
- data/spec/request/base/request_info_spec.rb +2 -2
- data/spec/request/base/request_keepalive_spec.rb +1 -1
- data/spec/request/peer/request_offer_spec.rb +1 -1
- data/spec/request/peer/request_trickle_spec.rb +1 -1
- data/spec/request/peer/request_trickles_spec.rb +1 -1
- data/spec/rrj/{rrj_spec.rb → ruby_rabbitmq_janus_spec.rb} +21 -11
- data/spec/{thread/concurencies_spec.rb → ruby_rabbitmq_janus/janus/concurrencies/concurrency_spec.rb} +1 -1
- data/spec/{thread → ruby_rabbitmq_janus/janus/concurrencies}/keepalive_initializer_spec.rb +3 -2
- data/spec/{thread → ruby_rabbitmq_janus/janus/concurrencies}/keepalive_thread_spec.rb +3 -3
- data/spec/{thread → ruby_rabbitmq_janus/janus/concurrencies}/keepalive_timer_spec.rb +1 -1
- data/spec/{rrj/messages/messages_admin_spec.rb → ruby_rabbitmq_janus/janus/messages/admin_spec.rb} +1 -1
- data/spec/{rrj/messages/messages_message_spec.rb → ruby_rabbitmq_janus/janus/messages/message_spec.rb} +2 -1
- data/spec/{rrj/messages/messages_standard_spec.rb → ruby_rabbitmq_janus/janus/messages/standard_spec.rb} +1 -1
- data/spec/{rrj/responses/responses_admin_spec.rb → ruby_rabbitmq_janus/janus/responses/admin_spec.rb} +1 -1
- data/spec/{rrj/responses/responses_event_spec.rb → ruby_rabbitmq_janus/janus/responses/event_spec.rb} +3 -2
- data/spec/{rrj/responses/responses_response_spec.rb → ruby_rabbitmq_janus/janus/responses/response_spec.rb} +3 -3
- data/spec/{rrj/responses/responses_standard_spec.rb → ruby_rabbitmq_janus/janus/responses/standard_spec.rb} +4 -3
- data/spec/{rrj → ruby_rabbitmq_janus}/models/janus_instance_definition_spec.rb +2 -2
- data/spec/{rrj/models/janus_instance_transaction_spec.rb → ruby_rabbitmq_janus/models/janus_instance_spec.rb} +10 -9
- data/spec/{rrj → ruby_rabbitmq_janus}/rabbit/connect_spec.rb +1 -1
- data/spec/ruby_rabbitmq_janus/rabbit/listener/from_spec.rb +15 -0
- data/spec/{rrj → ruby_rabbitmq_janus}/rabbit/propertie_2_spec.rb +3 -3
- data/spec/{rrj → ruby_rabbitmq_janus}/rabbit/propertie_spec.rb +3 -3
- data/spec/ruby_rabbitmq_janus/rabbit/publisher/admin_spec.rb +12 -0
- data/spec/{rrj/rabbit/publish/base_publisher_spec.rb → ruby_rabbitmq_janus/rabbit/publisher/base_spec.rb} +3 -3
- data/spec/{rrj/rabbit/publish → ruby_rabbitmq_janus/rabbit/publisher}/exclusive_spec.rb +0 -0
- data/spec/{rrj/rabbit/publish → ruby_rabbitmq_janus/rabbit/publisher}/non_exclusive_spec.rb +0 -0
- data/spec/{rrj/tools/gem/rrj_cluster_spec.rb → ruby_rabbitmq_janus/tools/cluster_spec.rb} +1 -21
- data/spec/{rrj/tools/gem/rrj_config_spec.rb → ruby_rabbitmq_janus/tools/config_spec.rb} +26 -14
- data/spec/{rrj/tools/gem/rrj_log_spec.rb → ruby_rabbitmq_janus/tools/log_spec.rb} +10 -10
- data/spec/{rrj/tools/replace/replace_admin_spec.rb → ruby_rabbitmq_janus/tools/replaces/admin_spec.rb} +15 -15
- data/spec/{rrj/tools/replace/replace_handle_spec.rb → ruby_rabbitmq_janus/tools/replaces/handle_spec.rb} +14 -14
- data/spec/{rrj/tools/replace → ruby_rabbitmq_janus/tools/replaces}/replace_spec.rb +16 -17
- data/spec/{rrj/tools/replace/replace_session_spec.rb → ruby_rabbitmq_janus/tools/replaces/session_spec.rb} +14 -14
- data/spec/{rrj/tools/replace → ruby_rabbitmq_janus/tools}/type_spec.rb +19 -19
- data/spec/spec_helper.rb +1 -1
- data/spec/support/examples_request.rb +1 -1
- data/spec/support/type.rb +3 -3
- metadata +83 -59
- data/lib/rrj/errors/rabbit/publish/admin.rb +0 -30
- data/lib/rrj/errors/rabbit/publish/base_publisher.rb +0 -23
- data/lib/rrj/errors/rabbit/publish/exclusive.rb +0 -31
- data/lib/rrj/errors/rabbit/publish/listener.rb +0 -30
- data/lib/rrj/errors/rabbit/publish/non_exclusive.rb +0 -31
- data/lib/rrj/errors/rabbit/publish/publisher.rb +0 -38
- data/lib/rrj/rabbit/publish/base_publisher.rb +0 -50
- data/spec/rrj/rabbit/publish/admin_spec.rb +0 -12
- data/spec/rrj/rabbit/publish/listener_spec.rb +0 -15
- data/spec/rrj/rabbit/publish/publisher_spec.rb +0 -13
@@ -11,12 +11,18 @@ module RubyRabbitmqJanus
|
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
+
require 'rrj/errors/rabbit/base_event'
|
14
15
|
require 'rrj/errors/rabbit/connect'
|
15
16
|
require 'rrj/errors/rabbit/propertie'
|
16
17
|
|
17
|
-
require 'rrj/errors/rabbit/
|
18
|
-
require 'rrj/errors/rabbit/
|
19
|
-
require 'rrj/errors/rabbit/
|
20
|
-
require 'rrj/errors/rabbit/
|
21
|
-
|
22
|
-
require 'rrj/errors/rabbit/
|
18
|
+
require 'rrj/errors/rabbit/listener/base'
|
19
|
+
require 'rrj/errors/rabbit/listener/from'
|
20
|
+
require 'rrj/errors/rabbit/listener/from_admin'
|
21
|
+
require 'rrj/errors/rabbit/listener/janus_instance'
|
22
|
+
|
23
|
+
require 'rrj/errors/rabbit/publisher/base'
|
24
|
+
require 'rrj/errors/rabbit/publisher/admin'
|
25
|
+
require 'rrj/errors/rabbit/publisher/exclusive'
|
26
|
+
require 'rrj/errors/rabbit/publisher/janus_instance'
|
27
|
+
require 'rrj/errors/rabbit/publisher/keepalive'
|
28
|
+
require 'rrj/errors/rabbit/publisher/non_exclusive'
|
data/lib/rrj/info.rb
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
# Define constant to gem.
|
7
7
|
module RubyRabbitmqJanus
|
8
8
|
# Define version to gem
|
9
|
-
VERSION = '2.
|
9
|
+
VERSION = '2.6.0'
|
10
10
|
|
11
11
|
# Name to gem
|
12
12
|
GEM_NAME = 'ruby_rabbitmq_janus'
|
@@ -35,11 +35,9 @@ module RubyRabbitmqJanus
|
|
35
35
|
# Define homepage
|
36
36
|
HOMEPAGE = 'https://github.com/dazzl-tv/ruby-rabbitmq-janus'
|
37
37
|
|
38
|
-
#
|
39
|
-
|
38
|
+
# Banner dazzl
|
39
|
+
BANNER = \
|
40
40
|
"# ====================================================== #\n" \
|
41
|
-
"# Thanks for installing RRJ ! #\n" \
|
42
|
-
"# #{HOMEPAGE}. #\n" \
|
43
41
|
"# ;;;;;;;;;;;:. #\n" \
|
44
42
|
"# ;;;;;;;;;;;;;;;;;; #\n" \
|
45
43
|
"# ;;;;;;;;;;;:;;;;;;;; #\n" \
|
@@ -54,4 +52,7 @@ module RubyRabbitmqJanus
|
|
54
52
|
"# ;;;;;;;;;;;;;;;;; AAAAA ZZ ZZ LL #\n" \
|
55
53
|
"# ;;;;;;;;;;;;;, A A ZZZZZZZ ZZZZZZZ LLLLLLL #\n" \
|
56
54
|
'# ====================================================== #'
|
55
|
+
|
56
|
+
# Define a post install message
|
57
|
+
POST_INSTALL = "#{HOMEPAGE}\n#{BANNER}"
|
57
58
|
end
|
data/lib/rrj/init.rb
CHANGED
@@ -39,8 +39,8 @@ module RubyRabbitmqJanus
|
|
39
39
|
# => #<RubyRabbitmqJanus::RRJ:0x007 @session=123>
|
40
40
|
def initialize
|
41
41
|
@option = Tools::Option.new
|
42
|
-
rescue =>
|
43
|
-
raise Errors::RRJ::InstanciateGem,
|
42
|
+
rescue => exception
|
43
|
+
raise Errors::RRJ::InstanciateGem, exception
|
44
44
|
end
|
45
45
|
|
46
46
|
# Start a transaction with Janus. Request use session_id information.
|
@@ -125,7 +125,8 @@ module RubyRabbitmqJanus
|
|
125
125
|
"Lookup Janus Instance model by session [#{@session}]"
|
126
126
|
Models::JanusInstance.find_by_session(@session)
|
127
127
|
end
|
128
|
-
rescue StandardError =>
|
128
|
+
rescue StandardError => exception
|
129
|
+
Tools::Log.debug exception
|
129
130
|
Tools::Log.instance.warn \
|
130
131
|
"find_model: rescuing from error #{e.message}"
|
131
132
|
nil
|
@@ -137,7 +138,7 @@ module RubyRabbitmqJanus
|
|
137
138
|
end
|
138
139
|
|
139
140
|
def publisher
|
140
|
-
Rabbit::Publisher::
|
141
|
+
Rabbit::Publisher::Keepalive.new(@rabbit.channel)
|
141
142
|
end
|
142
143
|
|
143
144
|
def response_session
|
@@ -0,0 +1,28 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'rrj/janus/responses/response'
|
4
|
+
|
5
|
+
module RubyRabbitmqJanus
|
6
|
+
module Janus
|
7
|
+
module Responses
|
8
|
+
# Janus Instanece response.
|
9
|
+
class JanusInstance < Response
|
10
|
+
def event
|
11
|
+
'JanusInstance update'
|
12
|
+
end
|
13
|
+
|
14
|
+
def id
|
15
|
+
request['id']
|
16
|
+
end
|
17
|
+
|
18
|
+
def instance
|
19
|
+
JanusInstance.find(id)
|
20
|
+
end
|
21
|
+
|
22
|
+
def enable
|
23
|
+
request['enable']
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
@@ -18,7 +18,7 @@ module RubyRabbitmqJanus
|
|
18
18
|
# Begin connection with RabbitMQ
|
19
19
|
def connect
|
20
20
|
rabbit.transaction_short do
|
21
|
-
@publisher = Rabbit::Publisher::
|
21
|
+
@publisher = Rabbit::Publisher::Admin.new(rabbit.channel)
|
22
22
|
yield
|
23
23
|
end
|
24
24
|
rescue
|
@@ -32,11 +32,11 @@ module RubyRabbitmqJanus
|
|
32
32
|
@publisher = if @exclusive
|
33
33
|
Tools::Log.instance.debug \
|
34
34
|
'Choose an queue Exclusive : ampq.gen-xxx'
|
35
|
-
Rabbit::Publisher::
|
35
|
+
Rabbit::Publisher::Exclusive.new(chan, '')
|
36
36
|
else
|
37
37
|
Tools::Log.instance.debug \
|
38
38
|
'Choose an queue non Exclusive : to-janus'
|
39
|
-
Rabbit::Publisher::
|
39
|
+
Rabbit::Publisher::NonExclusive.new(chan)
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
@@ -34,14 +34,11 @@ module RubyRabbitmqJanus
|
|
34
34
|
private
|
35
35
|
|
36
36
|
def create_a_session_in_janus_instance
|
37
|
-
|
38
|
-
janus_instance = keepalive_object_new
|
39
|
-
set(session: janus_instance.session)
|
37
|
+
RubyRabbitmqJanus::Rabbit::Publisher::JanusInstance.new.publish(message)
|
40
38
|
end
|
41
39
|
|
42
40
|
def destroy_a_session_in_janus_instance
|
43
|
-
|
44
|
-
unset(%I[thread thread_adm session])
|
41
|
+
RubyRabbitmqJanus::Rabbit::Publisher::JanusInstance.new.publish(message)
|
45
42
|
end
|
46
43
|
|
47
44
|
def keepalive_object
|
@@ -59,6 +56,13 @@ module RubyRabbitmqJanus
|
|
59
56
|
def info_instance(text)
|
60
57
|
Tools::Log.instance.debug "#{text} in Janus Instance [##{instance}]"
|
61
58
|
end
|
59
|
+
|
60
|
+
def message
|
61
|
+
{
|
62
|
+
id: id.to_s,
|
63
|
+
enable: enable
|
64
|
+
}
|
65
|
+
end
|
62
66
|
end
|
63
67
|
end
|
64
68
|
end
|
@@ -45,6 +45,18 @@ module RubyRabbitmqJanus
|
|
45
45
|
end
|
46
46
|
end
|
47
47
|
|
48
|
+
def create_keepalive
|
49
|
+
::Log.info 'Create session'
|
50
|
+
janus_instance = keepalive_object_new
|
51
|
+
set(session: janus_instance.session, enable: true)
|
52
|
+
end
|
53
|
+
|
54
|
+
def stop_keepalive
|
55
|
+
::Log.info 'Destroy session'
|
56
|
+
unset(%I[thread thread_adm session])
|
57
|
+
set(enable: false)
|
58
|
+
end
|
59
|
+
|
48
60
|
private
|
49
61
|
|
50
62
|
def search_initializer(options)
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'semaphore'
|
4
|
+
|
5
|
+
module RubyRabbitmqJanus
|
6
|
+
module Rabbit
|
7
|
+
# Define an module for create an publisher
|
8
|
+
# @author VAILLANT Jeremy <jeremy.vaillant@dazzl.tv>
|
9
|
+
|
10
|
+
# # Parent class for all publisher
|
11
|
+
# This element send and read a message in rabbitmq Queue
|
12
|
+
#
|
13
|
+
# @!attribute [r] response
|
14
|
+
# @return [RubyRabbitmqJanus::Janus::Responses::Response]
|
15
|
+
# Given a Janus response
|
16
|
+
#
|
17
|
+
# @abstract Publish message in RabbitMQ
|
18
|
+
class BaseEvent
|
19
|
+
attr_reader :responses
|
20
|
+
|
21
|
+
# Define a base publisher
|
22
|
+
def initialize
|
23
|
+
@responses = []
|
24
|
+
@semaphore = Semaphore.new
|
25
|
+
@lock = Mutex.new
|
26
|
+
rescue
|
27
|
+
raise Errors::Rabbit::BaseEvent::Initialize
|
28
|
+
end
|
29
|
+
|
30
|
+
private
|
31
|
+
|
32
|
+
attr_accessor :semaphore, :lock
|
33
|
+
|
34
|
+
def return_response
|
35
|
+
@semaphore.wait
|
36
|
+
response = nil
|
37
|
+
@lock.synchronize do
|
38
|
+
response = @responses.shift
|
39
|
+
end
|
40
|
+
response
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
require 'rrj/rabbit/publisher/base'
|
47
|
+
require 'rrj/rabbit/listener/base'
|
data/lib/rrj/rabbit/connect.rb
CHANGED
@@ -11,8 +11,8 @@ module RubyRabbitmqJanus
|
|
11
11
|
# Initialize connection to server RabbitMQ
|
12
12
|
def initialize
|
13
13
|
@rabbit = Bunny.new(read_options_server.merge!(option_log_rabbit))
|
14
|
-
rescue =>
|
15
|
-
raise Errors::Rabbit::Connect::Initialize,
|
14
|
+
rescue => exception
|
15
|
+
raise Errors::Rabbit::Connect::Initialize, exception
|
16
16
|
end
|
17
17
|
|
18
18
|
# Create an transaction with rabbitmq and close after response is received
|
@@ -20,37 +20,37 @@ module RubyRabbitmqJanus
|
|
20
20
|
response = transaction_long { yield }
|
21
21
|
close
|
22
22
|
response
|
23
|
-
rescue =>
|
24
|
-
raise Errors::Rabbit::Connect::TransactionShort,
|
23
|
+
rescue => exception
|
24
|
+
raise Errors::Rabbit::Connect::TransactionShort, exception
|
25
25
|
end
|
26
26
|
|
27
27
|
# Create an transaction with rabbitmq and not close
|
28
28
|
def transaction_long
|
29
29
|
start
|
30
30
|
yield
|
31
|
-
rescue =>
|
32
|
-
raise Errors::Rabbit::Connect::TransactionLong,
|
31
|
+
rescue => exception
|
32
|
+
raise Errors::Rabbit::Connect::TransactionLong, exception
|
33
33
|
end
|
34
34
|
|
35
35
|
# Openning a connection with Rabbitmq
|
36
36
|
def start
|
37
37
|
@rabbit.start
|
38
|
-
rescue =>
|
39
|
-
raise Errors::Rabbit::Connect::Start,
|
38
|
+
rescue => exception
|
39
|
+
raise Errors::Rabbit::Connect::Start, exception
|
40
40
|
end
|
41
41
|
|
42
42
|
# Close connection to server RabbitMQ
|
43
43
|
def close
|
44
44
|
@rabbit.close
|
45
|
-
rescue =>
|
46
|
-
raise Errors::Rabbit::Connect::Close,
|
45
|
+
rescue => exception
|
46
|
+
raise Errors::Rabbit::Connect::Close, exception
|
47
47
|
end
|
48
48
|
|
49
49
|
# Create an channel
|
50
50
|
def channel
|
51
51
|
@rabbit.create_channel
|
52
|
-
rescue =>
|
53
|
-
raise Errors::Rabbit::Connect::Channel,
|
52
|
+
rescue => exception
|
53
|
+
raise Errors::Rabbit::Connect::Channel, exception
|
54
54
|
end
|
55
55
|
|
56
56
|
private
|
@@ -4,13 +4,9 @@
|
|
4
4
|
|
5
5
|
module RubyRabbitmqJanus
|
6
6
|
module Rabbit
|
7
|
-
module
|
8
|
-
#
|
9
|
-
|
10
|
-
# This publisher don't post message. Is listen just an standard queue to
|
11
|
-
# Janus. By default is "from-janus". It's a parameter in config to this
|
12
|
-
# gem.
|
13
|
-
class Listener < BasePublisher
|
7
|
+
module Listener
|
8
|
+
# Base for listeners
|
9
|
+
class Base < RubyRabbitmqJanus::Rabbit::BaseEvent
|
14
10
|
# Define an publisher
|
15
11
|
#
|
16
12
|
# @param [String] rabbit Information connection to rabbitmq server
|
@@ -31,22 +27,13 @@ module RubyRabbitmqJanus
|
|
31
27
|
response = @responses.shift
|
32
28
|
end
|
33
29
|
yield response.event, response
|
34
|
-
rescue
|
30
|
+
rescue => exception
|
31
|
+
p exception
|
35
32
|
raise Errors::Rabbit::Listener::ListenEvents
|
36
33
|
end
|
37
34
|
|
38
35
|
private
|
39
36
|
|
40
|
-
def subscribe_queue
|
41
|
-
reply = @rabbit.queue(Tools::Config.instance.queue_from)
|
42
|
-
@rabbit.prefetch(1)
|
43
|
-
reply.bind(binding).subscribe(opts_subs) do |info, prop, payload|
|
44
|
-
Tools::Log.instance.info \
|
45
|
-
"[X] Message reading ##{prop['correlation_id']}"
|
46
|
-
synchronize_response(info, payload)
|
47
|
-
end
|
48
|
-
end
|
49
|
-
|
50
37
|
def binding
|
51
38
|
@rabbit.direct('amq.direct')
|
52
39
|
end
|
@@ -69,7 +56,18 @@ module RubyRabbitmqJanus
|
|
69
56
|
@rabbit.acknowledge(info.delivery_tag, false)
|
70
57
|
semaphore.signal
|
71
58
|
end
|
59
|
+
|
60
|
+
def info_subscribe(info, prop, payload)
|
61
|
+
Tools::Log.instance.debug info
|
62
|
+
Tools::Log.instance.info \
|
63
|
+
"[X] Message reading ##{prop['correlation_id']}"
|
64
|
+
Tools::Log.instance.debug payload
|
65
|
+
end
|
72
66
|
end
|
73
67
|
end
|
74
68
|
end
|
75
69
|
end
|
70
|
+
|
71
|
+
require 'rrj/rabbit/listener/from'
|
72
|
+
require 'rrj/rabbit/listener/from_admin'
|
73
|
+
require 'rrj/rabbit/listener/janus_instance'
|
@@ -0,0 +1,30 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
# :reek:TooManyStatements
|
4
|
+
|
5
|
+
module RubyRabbitmqJanus
|
6
|
+
module Rabbit
|
7
|
+
module Listener
|
8
|
+
# @author VAILLANT Jeremy <jeremy.vaillant@dazzl.tv>
|
9
|
+
#
|
10
|
+
# This publisher don't post message. Is listen just an standard queue to
|
11
|
+
# Janus. By default is "from-janus". It's a parameter in config to this
|
12
|
+
# gem.
|
13
|
+
class From < Base
|
14
|
+
private
|
15
|
+
|
16
|
+
def subscribe_queue
|
17
|
+
reply = @rabbit.queue(Tools::Config.instance.queue_from)
|
18
|
+
@rabbit.prefetch(1)
|
19
|
+
reply.bind(binding).subscribe(opts_subs) do |info, prop, payload|
|
20
|
+
info_subscribe(info, prop, payload)
|
21
|
+
synchronize_response(info, payload)
|
22
|
+
end
|
23
|
+
rescue => exception
|
24
|
+
raise RubyRabbitmqJanus::Errors::Rabbit::Listener::From::ListenEvents,
|
25
|
+
exception
|
26
|
+
end
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
@@ -4,19 +4,21 @@
|
|
4
4
|
|
5
5
|
module RubyRabbitmqJanus
|
6
6
|
module Rabbit
|
7
|
-
module
|
7
|
+
module Listener
|
8
8
|
# Listener to admin queue
|
9
|
-
class
|
9
|
+
class FromAdmin < From
|
10
10
|
private
|
11
11
|
|
12
12
|
def subscribe_queue
|
13
13
|
reply = @rabbit.queue(Tools::Config.instance.queue_admin_from)
|
14
14
|
@rabbit.prefetch(1)
|
15
15
|
reply.bind(binding).subscribe(opts_subs) do |info, prop, payload|
|
16
|
-
|
17
|
-
"[X] Message ADMIN reading ##{prop['correlation_id']}"
|
16
|
+
info_subscribe(info, prop, payload)
|
18
17
|
synchronize_response(info, payload)
|
19
18
|
end
|
19
|
+
rescue => exception
|
20
|
+
raise RubyRabbitmqJanus::Errors::Rabbit::Listener::From::ListenEvents,
|
21
|
+
exception
|
20
22
|
end
|
21
23
|
end
|
22
24
|
end
|