ruby_rabbitmq_janus 2.2.0.pre.170 → 2.2.0.pre.173
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/Rakefile +11 -1
- data/lib/rrj/errors/janus/janus.rb +0 -1
- data/lib/rrj/errors/janus/processus/concurency.rb +4 -1
- data/lib/rrj/errors/janus/processus/keepalive/initializer.rb +6 -14
- data/lib/rrj/errors/janus/processus/keepalive/thread.rb +38 -0
- data/lib/rrj/errors/janus/processus/keepalive/timer.rb +32 -1
- data/lib/rrj/janus/processus/keepalive/keepalive_initializer.rb +1 -1
- data/lib/rrj/janus/processus/keepalive/keepalive_message.rb +5 -0
- data/lib/rrj/janus/processus/keepalive/keepalive_thread.rb +40 -10
- data/lib/rrj/janus/processus/keepalive/keepalive_timer.rb +26 -7
- data/lib/rrj/models/active_record.rb +9 -0
- data/lib/rrj/models/concerns/janus_instance_callbacks.rb +3 -7
- data/lib/rrj/rabbit/connect.rb +2 -5
- data/lib/rrj/rabbit/propertie.rb +6 -10
- data/spec/spec_helper.rb +7 -5
- data/spec/thread/concurencies_spec.rb +11 -0
- data/spec/thread/keepalive_initializer_spec.rb +13 -0
- data/spec/thread/keepalive_thread_spec.rb +15 -0
- data/spec/thread/keepalive_timer_spec.rb +12 -0
- metadata +7 -4
- data/lib/config/default.yml +0 -28
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a1a3ff1ce8aa3114b1460ae38c996f1f6b1ff448
|
4
|
+
data.tar.gz: 8fcd100ec3e8a2b63e9c5a9f336692387aec9578
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6af6ba692c3978495df2c4ed85a577c781dcece26f97bcd299d66027fa1abe3e1a388f28eb74f63ef300c46253e0b045fd6004c939c186c513a92478aed2c4b3
|
7
|
+
data.tar.gz: 7206fd1211726ade7c54c211427da91de8de09b751126648130e1df1c7af101e62bd1da93ed33b867e678180e416c692c7e541621b8dcfabacfe687a879b9919
|
data/Rakefile
CHANGED
@@ -3,6 +3,16 @@
|
|
3
3
|
require 'bundler/gem_tasks'
|
4
4
|
require 'rspec/core/rake_task'
|
5
5
|
|
6
|
-
|
6
|
+
# Exclude all spec with type :thread
|
7
|
+
RSpec::Core::RakeTask.new(:spec) do |t|
|
8
|
+
t.rspec_opts = '--tag ~type:thread'
|
9
|
+
end
|
10
|
+
|
11
|
+
# Include just spec with type :thread
|
12
|
+
RSpec::Core::RakeTask.new(:concurrency) do |t|
|
13
|
+
t.rspec_opts = '--tag type:thread'
|
14
|
+
end
|
7
15
|
|
8
16
|
task default: :spec
|
17
|
+
|
18
|
+
task thread: :concurrency
|
@@ -6,7 +6,7 @@ module RubyRabbitmqJanus
|
|
6
6
|
# Define a super class for all error in Janus::Concurency class
|
7
7
|
class BaseConcurency < RubyRabbitmqJanus::Errors::BaseJanus
|
8
8
|
def initialize(message)
|
9
|
-
super "[Concurency]
|
9
|
+
super "[Concurency]#{message}", :fatal
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
@@ -21,3 +21,6 @@ module RubyRabbitmqJanus
|
|
21
21
|
end
|
22
22
|
end
|
23
23
|
end
|
24
|
+
|
25
|
+
require 'rrj/errors/janus/processus/keepalive'
|
26
|
+
require 'rrj/errors/janus/processus/event'
|
@@ -1,14 +1,10 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
3
|
# :reek:IrresponsibleModule
|
4
|
-
#
|
5
|
-
# rubocop:disable Metrics/LineLength
|
6
|
-
# rubocop:disable Style/Documentation
|
7
4
|
|
8
5
|
module RubyRabbitmqJanus
|
9
6
|
module Errors
|
10
7
|
module Janus
|
11
|
-
# Define a super class for all error in Janus::Concurency::Keepalive
|
12
8
|
class BaseKeepaliveInitializer < BaseKeepalive
|
13
9
|
def initialize(message)
|
14
10
|
super "[Initializer] #{message}"
|
@@ -16,40 +12,38 @@ module RubyRabbitmqJanus
|
|
16
12
|
end
|
17
13
|
|
18
14
|
module KeepaliveInitializer
|
19
|
-
# Error for Janus::Concurency::Keepalive#initialize
|
20
15
|
class Initializer < RubyRabbitmqJanus::Errors::Janus::BaseKeepaliveInitializer
|
21
|
-
def
|
16
|
+
def initialize
|
22
17
|
super 'Error keepalive initializer'
|
23
18
|
end
|
24
19
|
end
|
25
20
|
|
26
|
-
# Error for Janus::Concurency::Keepalive#session
|
27
21
|
class Session < RubyRabbitmqJanus::Errors::Janus::BaseKeepaliveInitializer
|
28
|
-
def
|
22
|
+
def initialize
|
29
23
|
super 'Error return session number'
|
30
24
|
end
|
31
25
|
end
|
32
26
|
|
33
27
|
class Thread < RubyRabbitmqJanus::Errors::Janus::BaseKeepaliveInitializer
|
34
|
-
def
|
28
|
+
def initialize
|
35
29
|
super 'Error for get Object Thread ID'
|
36
30
|
end
|
37
31
|
end
|
38
32
|
|
39
33
|
class ThreadStart < RubyRabbitmqJanus::Errors::Janus::BaseKeepaliveInitializer
|
40
|
-
def
|
34
|
+
def initialize
|
41
35
|
super 'Error for starting timer in thread'
|
42
36
|
end
|
43
37
|
end
|
44
38
|
|
45
39
|
class ThreadStop < RubyRabbitmqJanus::Errors::Janus::BaseKeepaliveInitializer
|
46
|
-
def
|
40
|
+
def initialize
|
47
41
|
super 'Error for stoping timer in thread'
|
48
42
|
end
|
49
43
|
end
|
50
44
|
|
51
45
|
class ThreadDelete < RubyRabbitmqJanus::Errors::Janus::BaseKeepaliveInitializer
|
52
|
-
def
|
46
|
+
def initialize
|
53
47
|
super 'Error for destroy thread'
|
54
48
|
end
|
55
49
|
end
|
@@ -57,5 +51,3 @@ module RubyRabbitmqJanus
|
|
57
51
|
end
|
58
52
|
end
|
59
53
|
end
|
60
|
-
# rubocop:enable Style/Documentation
|
61
|
-
# rubocop:enable Metrics/LineLength
|
@@ -11,6 +11,44 @@ module RubyRabbitmqJanus
|
|
11
11
|
super "[Thread] #{message}"
|
12
12
|
end
|
13
13
|
end
|
14
|
+
|
15
|
+
module KeepaliveThread
|
16
|
+
class Initializer < RubyRabbitmqJanus::Errors::Janus::BaseKeepaliveThread
|
17
|
+
def initialize
|
18
|
+
super 'Error for initialize Keepalive Thread'
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
class InitializeJanusSession < RubyRabbitmqJanus::Errors::Janus::BaseKeepaliveThread
|
23
|
+
def initialize
|
24
|
+
super 'Error when initialize message in keepalive thread'
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
class RestartSession < RubyRabbitmqJanus::Errors::Janus::BaseKeepaliveThread
|
29
|
+
def initialize
|
30
|
+
super 'Error when restart session'
|
31
|
+
end
|
32
|
+
end
|
33
|
+
|
34
|
+
class Start < RubyRabbitmqJanus::Errors::Janus::BaseKeepaliveThread
|
35
|
+
def initialize
|
36
|
+
super 'Error when start a loop for sending keepalive message'
|
37
|
+
end
|
38
|
+
end
|
39
|
+
|
40
|
+
class Kill < RubyRabbitmqJanus::Errors::Janus::BaseKeepaliveThread
|
41
|
+
def initialize
|
42
|
+
super 'Error when killing thread'
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
class InstanceIsDown < RubyRabbitmqJanus::Errors::Janus::BaseKeepaliveThread
|
47
|
+
def initialize
|
48
|
+
super 'Error when instance is down'
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
14
52
|
end
|
15
53
|
end
|
16
54
|
end
|
@@ -5,12 +5,43 @@
|
|
5
5
|
module RubyRabbitmqJanus
|
6
6
|
module Errors
|
7
7
|
module Janus
|
8
|
-
# Define a super class for all error in Janus::Concurency::Keepalive
|
9
8
|
class BaseKeepaliveTimer < BaseKeepalive
|
10
9
|
def initialize(message)
|
11
10
|
super "[Timer] #{message}"
|
12
11
|
end
|
13
12
|
end
|
13
|
+
|
14
|
+
module KeepaliveTimer
|
15
|
+
class Initializer < RubyRabbitmqJanus::Errors::Janus::BaseKeepaliveTimer
|
16
|
+
def initialize
|
17
|
+
super 'Error for initialize Keepalive Timer'
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
class LoopKeepalive < RubyRabbitmqJanus::Errors::Janus::BaseKeepaliveTimer
|
22
|
+
def initialize
|
23
|
+
super 'Loop for create timer in Keepalive Thread is failed'
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
class Session < RubyRabbitmqJanus::Errors::Janus::BaseKeepaliveTimer
|
28
|
+
def initialize
|
29
|
+
super 'Timeout for get session number in keepalive request'
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
class StopTimer < RubyRabbitmqJanus::Errors::Janus::BaseKeepaliveTimer
|
34
|
+
def initialize
|
35
|
+
super 'Error when timer to Keepalive Thread stop'
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
class StartTimer < RubyRabbitmqJanus::Errors::Janus::BaseKeepaliveTimer
|
40
|
+
def initialize
|
41
|
+
super 'Error when timer to Keepalive Thread start'
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
14
45
|
end
|
15
46
|
end
|
16
47
|
end
|
@@ -26,7 +26,7 @@ module RubyRabbitmqJanus
|
|
26
26
|
def self.thread(thread)
|
27
27
|
ObjectSpace._id2ref(thread)
|
28
28
|
rescue RangeError
|
29
|
-
|
29
|
+
Tools::Log.instance.fatal "No thread with ID : #{thread}"
|
30
30
|
end
|
31
31
|
|
32
32
|
# Give a session Integer his gem is instantiate.
|
@@ -6,7 +6,12 @@ module RubyRabbitmqJanus
|
|
6
6
|
module Janus
|
7
7
|
module Concurrencies
|
8
8
|
# Manage message used for keepalive thread
|
9
|
+
#
|
10
|
+
# @attribute [r] instance
|
11
|
+
# @return [String] ID to Janus Instance
|
9
12
|
class KeepaliveMessage
|
13
|
+
attr_reader :instance
|
14
|
+
|
10
15
|
def initialize(instance)
|
11
16
|
@instance = instance
|
12
17
|
end
|
@@ -5,9 +5,12 @@
|
|
5
5
|
module RubyRabbitmqJanus
|
6
6
|
module Janus
|
7
7
|
module Concurrencies
|
8
|
-
# Object thread
|
8
|
+
# Object thread for manage keep a live with Janus Instance
|
9
|
+
#
|
10
|
+
# @!attribute [r] session
|
11
|
+
# @return [Integer] Number to session linked to Janus Instance
|
9
12
|
class KeepaliveThread < Thread
|
10
|
-
attr_reader :timer, :
|
13
|
+
attr_reader :timer, :session
|
11
14
|
|
12
15
|
def initialize(instance, rabbit, &block)
|
13
16
|
@publisher = @session = nil
|
@@ -15,6 +18,8 @@ module RubyRabbitmqJanus
|
|
15
18
|
@timer = KeepaliveTimer.new
|
16
19
|
@message = KeepaliveMessage.new(instance)
|
17
20
|
super(&block)
|
21
|
+
rescue
|
22
|
+
raise Errors::Janus::KeepaliveThread::Initializer
|
18
23
|
end
|
19
24
|
|
20
25
|
# Initialize a transaction with Janus Instance.
|
@@ -22,41 +27,66 @@ module RubyRabbitmqJanus
|
|
22
27
|
def initialize_janus_session
|
23
28
|
@publisher = publisher
|
24
29
|
@session = response_session
|
30
|
+
rescue
|
31
|
+
raise Errors::Janus::KeepaliveThread::InitializeJanusSession
|
25
32
|
end
|
26
33
|
|
27
34
|
# Restart session
|
28
35
|
def restart_session
|
29
36
|
Tools::Log.instance.warn 'Restart session ...'
|
30
|
-
janus = find_model
|
31
37
|
@session = response_session
|
32
38
|
response_keepalive
|
33
|
-
|
39
|
+
find_model.set(session: @session)
|
40
|
+
rescue
|
41
|
+
raise Errors::Janus::KeepaliveThread::RestartSession
|
34
42
|
end
|
35
43
|
|
36
44
|
# Start a timer for TTL
|
37
45
|
def start
|
38
|
-
@timer.loop_keepalive
|
46
|
+
@timer.loop_keepalive do
|
47
|
+
Tools::Log.instance.info 'Send keepalive to instance ' \
|
48
|
+
"#{@message.instance} with TTL #{@timer.time_to_live}"
|
49
|
+
response_keepalive
|
50
|
+
end
|
51
|
+
rescue
|
52
|
+
raise Errors::Janus::KeepaliveThread::Start
|
39
53
|
end
|
40
54
|
|
41
55
|
# Kill session and disable instance
|
42
56
|
def kill
|
43
|
-
|
57
|
+
if @session.present? && @message.present?
|
58
|
+
response_destroy if find_model.enable
|
59
|
+
end
|
44
60
|
super
|
61
|
+
rescue
|
62
|
+
raise Errors::Janus::KeepaliveThread::Kill
|
45
63
|
end
|
46
64
|
|
47
65
|
def instance_is_down
|
48
66
|
janus = find_model
|
49
|
-
janus.set(enable: false)
|
50
|
-
|
67
|
+
janus.set(enable: false).unset(%I[thread session])
|
51
68
|
Tools::Log.instance.fatal \
|
52
69
|
"Janus Instance [#{janus.instance}] is down, kill thread."
|
53
|
-
|
70
|
+
prepare_kill_thread
|
71
|
+
rescue
|
72
|
+
raise Errors::Janus::KeepaliveThread::InstanceIsDown
|
54
73
|
end
|
55
74
|
|
56
75
|
private
|
57
76
|
|
77
|
+
attr_reader :instance
|
78
|
+
|
79
|
+
def prepare_kill_thread
|
80
|
+
@session = @message = nil
|
81
|
+
KeepaliveThread.instance_method(:kill).bind(self).call
|
82
|
+
end
|
83
|
+
|
58
84
|
def find_model
|
59
|
-
|
85
|
+
if @session.blank?
|
86
|
+
Models::JanusInstance.find(@message.instance)
|
87
|
+
else
|
88
|
+
Models::JanusInstance.find_by_session(@session)
|
89
|
+
end
|
60
90
|
end
|
61
91
|
|
62
92
|
def publisher
|
@@ -3,6 +3,8 @@
|
|
3
3
|
require 'timeout'
|
4
4
|
require 'timers'
|
5
5
|
|
6
|
+
# :reek:DuplicateMethodCall
|
7
|
+
|
6
8
|
module RubyRabbitmqJanus
|
7
9
|
module Janus
|
8
10
|
module Concurrencies
|
@@ -11,16 +13,21 @@ module RubyRabbitmqJanus
|
|
11
13
|
# # Manage time for thread
|
12
14
|
#
|
13
15
|
# Configure all timer used in keepalive class
|
16
|
+
#
|
17
|
+
# @!attribute [r] time_to_live
|
18
|
+
# @return [Integer] Time for interval between keepalive message
|
19
|
+
# @!attribute [r] time_to_die
|
20
|
+
# @return [Integer] Time before timer stop it
|
14
21
|
class KeepaliveTimer
|
22
|
+
attr_reader :time_to_live, :time_to_die
|
23
|
+
|
15
24
|
# Initialize timer to keeaplive thread.
|
16
|
-
# Configure timer with :
|
17
|
-
# - interval for each keepalive message
|
18
|
-
# - timeout for session response
|
19
|
-
# - timeout for publish message
|
20
25
|
def initialize
|
21
26
|
@time_to_live = Tools::Config.instance.ttl
|
22
|
-
@
|
27
|
+
@time_to_die = test_time_to_die >= 60 ? 59 : test_time_to_die
|
23
28
|
@timer = Timers::Group.new
|
29
|
+
rescue
|
30
|
+
raise Errors::Janus::KeepaliveTimer::Initializer
|
24
31
|
end
|
25
32
|
|
26
33
|
# Execute a loop with timer for sending keepalive message
|
@@ -28,36 +35,48 @@ module RubyRabbitmqJanus
|
|
28
35
|
def loop_keepalive(&block)
|
29
36
|
@timer.now_and_every(@time_to_live) { prepare_loop(&block) }
|
30
37
|
loop { @timer.wait }
|
38
|
+
rescue
|
39
|
+
raise Errors::Janus::KeepaliveTimer::LoopKeepalive
|
31
40
|
end
|
32
41
|
|
33
42
|
# Test if session is present/exist in Janus Instance
|
34
43
|
def session(&block)
|
35
|
-
Timeout.timeout(@
|
44
|
+
Timeout.timeout(@time_to_die) { yield }
|
36
45
|
rescue Timeout::Error
|
37
46
|
stop_timer
|
38
47
|
block.binding.receiver.instance_is_down
|
48
|
+
rescue
|
49
|
+
raise Errors::Janus::KeepaliveTimer::Session
|
39
50
|
end
|
40
51
|
|
41
52
|
# Stop timer to keepalive thread
|
42
53
|
def stop_timer
|
43
54
|
@timer.pause
|
55
|
+
rescue
|
56
|
+
raise Errors::Janus::KeepaliveTimer::StopTimer
|
44
57
|
end
|
45
58
|
|
46
59
|
# Start timer to keepalive thread
|
47
60
|
def start_timer
|
48
61
|
@timer.resume
|
62
|
+
rescue
|
63
|
+
raise Errors::Janus::KeepaliveTimer::StartTimer
|
49
64
|
end
|
50
65
|
|
51
66
|
private
|
52
67
|
|
53
68
|
def prepare_loop(&block)
|
54
|
-
Timeout.timeout(@
|
69
|
+
Timeout.timeout(@time_to_die) do
|
55
70
|
block.binding.receiver.restart_session if yield
|
56
71
|
end
|
57
72
|
rescue Timeout::Error
|
58
73
|
stop_timer
|
59
74
|
block.binding.receiver.instance_is_down
|
60
75
|
end
|
76
|
+
|
77
|
+
def test_time_to_die
|
78
|
+
@time_to_live + 5
|
79
|
+
end
|
61
80
|
end
|
62
81
|
end
|
63
82
|
end
|
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
# :reek:UtilityFunction
|
4
|
+
|
3
5
|
module RubyRabbitmqJanus
|
4
6
|
module Models
|
5
7
|
# @author VAILLANT Jeremy <jeremy.vaillant@dazzl.tv>
|
@@ -26,6 +28,13 @@ module RubyRabbitmqJanus
|
|
26
28
|
def set(attributes)
|
27
29
|
update_columns(attributes)
|
28
30
|
end
|
31
|
+
|
32
|
+
# Destroy data to column
|
33
|
+
#
|
34
|
+
# @param [Array] List to attribute to delete in document
|
35
|
+
def unset(attributes)
|
36
|
+
Hash[attributes.map { |key, _value| [key, nil] }]
|
37
|
+
end
|
29
38
|
end
|
30
39
|
end
|
31
40
|
end
|
@@ -20,7 +20,7 @@ module RubyRabbitmqJanus
|
|
20
20
|
if enable && enable_changed?
|
21
21
|
create_a_session_in_janus_instance
|
22
22
|
elsif !enable && enable_changed?
|
23
|
-
|
23
|
+
destroy_a_session_in_janus_instance
|
24
24
|
end
|
25
25
|
end
|
26
26
|
|
@@ -38,15 +38,11 @@ module RubyRabbitmqJanus
|
|
38
38
|
set(session: janus_instance.session, thread: janus_instance.thread_id)
|
39
39
|
end
|
40
40
|
|
41
|
-
def disable_a_session_in_janus_instance
|
42
|
-
info_instance('Destroy session')
|
43
|
-
keepalive_object_thread.kill
|
44
|
-
unset(%I[thread session])
|
45
|
-
end
|
46
|
-
|
47
41
|
def destroy_a_session_in_janus_instance
|
48
42
|
info_instance('Destroy session')
|
43
|
+
keepalive_object_thread.send(:response_destroy)
|
49
44
|
keepalive_object_thread.kill
|
45
|
+
unset(%I[thread session])
|
50
46
|
end
|
51
47
|
|
52
48
|
def keepalive_object
|
data/lib/rrj/rabbit/connect.rb
CHANGED
@@ -56,12 +56,9 @@ module RubyRabbitmqJanus
|
|
56
56
|
private
|
57
57
|
|
58
58
|
def read_options_server
|
59
|
+
conn = %w[host port pass user vhost]
|
59
60
|
cfg = Tools::Config.instance.options['rabbit']
|
60
|
-
|
61
|
-
%w[host port pass user vhost].each do |val|
|
62
|
-
opts.merge!(val.to_sym => cfg[val])
|
63
|
-
end
|
64
|
-
opts
|
61
|
+
Hash[conn.map { |value| [value.to_sym, cfg[value]] }]
|
65
62
|
end
|
66
63
|
|
67
64
|
def option_log_rabbit
|
data/lib/rrj/rabbit/propertie.rb
CHANGED
@@ -22,22 +22,14 @@ module RubyRabbitmqJanus
|
|
22
22
|
|
23
23
|
# Define options sending to rabbitmq
|
24
24
|
def options
|
25
|
-
|
26
|
-
routing_key: Tools::Cluster.instance.queue_to(@instance),
|
27
|
-
correlation_id: @correlation,
|
28
|
-
content_type: 'application/json'
|
29
|
-
}
|
25
|
+
base.merge(routing_key: Tools::Cluster.instance.queue_to(@instance))
|
30
26
|
rescue
|
31
27
|
raise Errors::Rabbit::Propertie::Options
|
32
28
|
end
|
33
29
|
|
34
30
|
# Define option sending to rabbitmq for janus admin message
|
35
31
|
def options_admin(type_request)
|
36
|
-
|
37
|
-
routing_key: determine_routing_key(type_request),
|
38
|
-
correlation_id: @correlation,
|
39
|
-
content_type: 'application/json'
|
40
|
-
}
|
32
|
+
base.merge(routing_key: determine_routing_key(type_request))
|
41
33
|
rescue
|
42
34
|
raise Errors::Rabbit::Propertie::Options_admin
|
43
35
|
end
|
@@ -53,6 +45,10 @@ module RubyRabbitmqJanus
|
|
53
45
|
cluster.queue_to(@instance)
|
54
46
|
end
|
55
47
|
end
|
48
|
+
|
49
|
+
def base
|
50
|
+
{ correlation_id: @correlation, content_type: 'application/json' }
|
51
|
+
end
|
56
52
|
end
|
57
53
|
end
|
58
54
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -6,7 +6,7 @@ require 'json-schema-rspec'
|
|
6
6
|
require 'rails'
|
7
7
|
require 'factory_girl'
|
8
8
|
require 'database_cleaner'
|
9
|
-
ENV['MONGO']='true' if ENV['MONGO'].nil?
|
9
|
+
ENV['MONGO'] = 'true' if ENV['MONGO'].nil?
|
10
10
|
require ENV['MONGO'].match?('true') ? 'mongoid' : 'active_record'
|
11
11
|
|
12
12
|
require 'ruby_rabbitmq_janus'
|
@@ -28,7 +28,6 @@ end
|
|
28
28
|
RSpec.configure do |config|
|
29
29
|
DatabaseCleaner.strategy = :truncation
|
30
30
|
ENV['MONGO'].match?('true') ? load_mongo : load_active_record
|
31
|
-
after_load_database
|
32
31
|
|
33
32
|
config.expect_with :rspec do |c|
|
34
33
|
c.syntax = :expect
|
@@ -60,8 +59,11 @@ RSpec.configure do |config|
|
|
60
59
|
|
61
60
|
# Configure Initializer RRJ and create session with Janus Instance
|
62
61
|
config.before(:example) do |example|
|
63
|
-
|
64
|
-
|
65
|
-
|
62
|
+
unless example.metadata[:type].match?(/thread/) || example.metadata[:type].match?(/tools/)
|
63
|
+
after_load_database
|
64
|
+
initializer_rrj(example.metadata)
|
65
|
+
clear
|
66
|
+
find_instance
|
67
|
+
end
|
66
68
|
end
|
67
69
|
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe RubyRabbitmqJanus::Janus::Concurrencies::Concurrency, type: :thread, name: :concurrency do
|
6
|
+
let(:concurrency) { RubyRabbitmqJanus::Janus::Concurrencies::Concurrency.new }
|
7
|
+
|
8
|
+
it { expect(concurrency.send(:rabbit)).to be_a(RubyRabbitmqJanus::Rabbit::Connect) }
|
9
|
+
it { expect(concurrency.send(:lock)).to be_a(Mutex) }
|
10
|
+
it { expect(concurrency.send(:condition)).to be_a(ConditionVariable) }
|
11
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe RubyRabbitmqJanus::Janus::Concurrencies::KeepaliveThread, type: :thread, name: :keepalive_initializer do
|
6
|
+
let(:instance) { [1, 2].sample }
|
7
|
+
let(:concurrency) { RubyRabbitmqJanus::Janus::Concurrencies::KeepaliveInitializer.new(instance) }
|
8
|
+
|
9
|
+
it { expect(concurrency.send(:rabbit)).to be_a(RubyRabbitmqJanus::Rabbit::Connect) }
|
10
|
+
it { expect(concurrency.send(:lock)).to be_a(Mutex) }
|
11
|
+
it { expect(concurrency.send(:condition)).to be_a(ConditionVariable) }
|
12
|
+
it { expect(concurrency.instance_variable_get(:@thread)).to be_a(RubyRabbitmqJanus::Janus::Concurrencies::KeepaliveThread) }
|
13
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe RubyRabbitmqJanus::Janus::Concurrencies::KeepaliveThread, type: :thread, name: :keepalive_thread do
|
6
|
+
let(:instance) { [1, 2].sample }
|
7
|
+
let(:rabbit) { RubyRabbitmqJanus::Janus::Concurrencies::Concurrency.new.send(:rabbit) }
|
8
|
+
let(:concurrency) { RubyRabbitmqJanus::Janus::Concurrencies::KeepaliveThread.new(instance, rabbit) { nil } }
|
9
|
+
|
10
|
+
it { expect(concurrency.instance_variable_get(:@session)).to eql(nil) }
|
11
|
+
it { expect(concurrency.instance_variable_get(:@publisher)).to eql(nil) }
|
12
|
+
it { expect(concurrency.instance_variable_get(:@rabbit)).to be_a(RubyRabbitmqJanus::Rabbit::Connect) }
|
13
|
+
it { expect(concurrency.instance_variable_get(:@timer)).to be_a(RubyRabbitmqJanus::Janus::Concurrencies::KeepaliveTimer) }
|
14
|
+
it { expect(concurrency.instance_variable_get(:@message)).to be_a(RubyRabbitmqJanus::Janus::Concurrencies::KeepaliveMessage) }
|
15
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe RubyRabbitmqJanus::Janus::Concurrencies::KeepaliveTimer, type: :thread, name: :keepalive_timer do
|
6
|
+
let(:concurrency) { RubyRabbitmqJanus::Janus::Concurrencies::KeepaliveTimer.new }
|
7
|
+
|
8
|
+
it { expect(concurrency.send(:time_to_live)).to be_a(Integer) }
|
9
|
+
it { expect(concurrency.send(:time_to_die)).to be_a(Integer) }
|
10
|
+
it { expect(concurrency.instance_variable_get(:@timer)).to be_a(Timers::Group) }
|
11
|
+
it { expect(concurrency.instance_variable_get(:@time_to_live)).to eql(RubyRabbitmqJanus::Tools::Config.instance.options['janus']['session']['keepalive']) }
|
12
|
+
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.2.0.pre.
|
4
|
+
version: 2.2.0.pre.173
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- VAILLANT Jeremy
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-09-
|
11
|
+
date: 2017-09-14 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -398,7 +398,6 @@ files:
|
|
398
398
|
- config/requests/peer/answer.json
|
399
399
|
- config/requests/peer/offer.json
|
400
400
|
- config/requests/peer/trickle.json
|
401
|
-
- lib/config/default.yml
|
402
401
|
- lib/generators/ruby_rabbitmq_janus/configuration_generator.rb
|
403
402
|
- lib/generators/ruby_rabbitmq_janus/create_request_generator.rb
|
404
403
|
- lib/generators/ruby_rabbitmq_janus/default_request_generator.rb
|
@@ -577,6 +576,10 @@ files:
|
|
577
576
|
- spec/support/schemas/request/peer/trickle.json
|
578
577
|
- spec/support/sdp.rb
|
579
578
|
- spec/support/type.rb
|
579
|
+
- spec/thread/concurencies_spec.rb
|
580
|
+
- spec/thread/keepalive_initializer_spec.rb
|
581
|
+
- spec/thread/keepalive_thread_spec.rb
|
582
|
+
- spec/thread/keepalive_timer_spec.rb
|
580
583
|
homepage: https://github.com/dazzl-tv/ruby-rabbitmq-janus
|
581
584
|
licenses:
|
582
585
|
- MIT
|
@@ -614,7 +617,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
614
617
|
version: 1.3.1
|
615
618
|
requirements: []
|
616
619
|
rubyforge_project:
|
617
|
-
rubygems_version: 2.6.
|
620
|
+
rubygems_version: 2.6.13
|
618
621
|
signing_key:
|
619
622
|
specification_version: 4
|
620
623
|
summary: Ruby RabbitMQ Janus
|
data/lib/config/default.yml
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
rabbit:
|
2
|
-
host: rabbit.dazzl.local
|
3
|
-
port: 5672
|
4
|
-
vhost: /
|
5
|
-
user: dazzl_api
|
6
|
-
pass: SuWYeg2d
|
7
|
-
admin_pass: Guj9khoN
|
8
|
-
level: info
|
9
|
-
|
10
|
-
queues:
|
11
|
-
standard:
|
12
|
-
from: from-janus
|
13
|
-
to: to-janus
|
14
|
-
admin:
|
15
|
-
from: from-janus-admin
|
16
|
-
to: to-janus-admin
|
17
|
-
|
18
|
-
janus:
|
19
|
-
session:
|
20
|
-
keepalive: 55
|
21
|
-
plugins:
|
22
|
-
- janus.plugin.dazzl.videocontrol
|
23
|
-
|
24
|
-
gem:
|
25
|
-
cluster:
|
26
|
-
enabled: true
|
27
|
-
log:
|
28
|
-
level: debug
|