ruby_rabbitmq_janus 2.7.2.pre.312 → 2.7.2.pre.314

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: eeaab1ae4e6c2b315a48d3dae5779098d70749ca0426fd7a7752dd95d0914bfe
4
- data.tar.gz: 71f20a5706f6021718bf0491e3cea0afd1e84b308f03bfc61289286f6ec1c2e0
3
+ metadata.gz: 55ec8d50d1bce0633eaa064cfe14a12107e214423b133246d22a684edd6c52ce
4
+ data.tar.gz: 074e93f780f98a747ffdbeece4d5ec0f28fa2e898372a426546f9115f4f02506
5
5
  SHA512:
6
- metadata.gz: bfb041a82fc30acae2b546cf1455609b7b6e7bf5bd0bd509a6157860ae184232a9bfce67c509924aa1136e1b4e24a9ea63c11fc044f8f3094ce2329af65cf733
7
- data.tar.gz: 8fed4a682590c5699402da12c9cedd700d2fe150ea48febcfdc1e16906bb0c50d95612914b2c57773fb0711bd45d0802dff74742c5ae2ce77c664d1af35569ca
6
+ metadata.gz: 2407c36de8b7d0bee62bf06575e8ceaba9266d3481c332d9d15fd7d3861e42504c07fd40dac9271a156bc937cbf4c42ec84f4326b013ed22e981edfcb8ee9fae
7
+ data.tar.gz: c47053c454305a155a58ba6cacecef9fd0b7074e85d667fb8a264e061eaee3db1330c6aa3fbcf4134d07862c40da1937d631e5bd219624b57f82799a430965dc
@@ -9,8 +9,6 @@ module RubyRabbitmqJanus
9
9
  # Store instance information for MongoID database
10
10
  class JanusInstance < ::ActiveRecord::Base
11
11
  include RubyRabbitmqJanus::Models::Instances
12
- # include RubyRabbitmqJanus::Models::Methods
13
- # include RubyRabbitmqJanus::Models::Callbacks
14
12
  include RubyRabbitmqJanus::Models::Validations
15
13
 
16
14
  self.primary_key = :id
@@ -18,12 +16,6 @@ module RubyRabbitmqJanus
18
16
  alias_attribute :instance, :id
19
17
  alias_attribute :title, :name
20
18
  alias_attribute :session_id, :session
21
- alias_attribute :thread_id, :thread
22
- alias_attribute :thread_id_adm, :thread_adm
23
-
24
- # after_create { callback_create_after }
25
- # after_update { callback_update_after }
26
- # after_destroy { callback_destroy_after }
27
19
 
28
20
  # Update attributes to document
29
21
  #
@@ -8,21 +8,13 @@ module RubyRabbitmqJanus
8
8
  class JanusInstance
9
9
  include Mongoid::Document
10
10
  include RubyRabbitmqJanus::Models::Instances
11
- # include RubyRabbitmqJanus::Models::Methods
12
- # include RubyRabbitmqJanus::Models::Callbacks
13
11
  include RubyRabbitmqJanus::Models::Validations
14
12
 
15
13
  field :name, type: String, as: :title
16
14
  field :session, type: Integer, as: :session_id
17
15
  field :enable, type: Boolean
18
- field :thread, type: Integer, as: :thread_id
19
- field :thread_adm, type: Integer, as: :thread_id_adm
20
16
 
21
17
  alias_attribute :instance, :_id
22
-
23
- # set_callback(:create, :after) { callback_create_after }
24
- # set_callback(:update, :after) { callback_update_after }
25
- # set_callback(:destroy, :after) { callback_destroy_after }
26
18
  end
27
19
  end
28
20
  end
@@ -8,8 +8,9 @@ module RubyRabbitmqJanus
8
8
  #
9
9
  # # Class for manage threads
10
10
  #
11
- # @abstract Manage thread in this gem for keepalive message and listen
12
- # standard queue.
11
+ # @abstract Manage thread for listener to queue :
12
+ # from-janus
13
+ # from-janus-admin
13
14
  class Concurrency
14
15
  # Initialize class with elements for thread communication
15
16
  def initialize
@@ -40,6 +41,5 @@ module RubyRabbitmqJanus
40
41
  end
41
42
  end
42
43
 
43
- require 'rrj/process/keepalive/keepalive_initializer'
44
44
  require 'rrj/process/event'
45
45
  require 'rrj/process/event_admin'
@@ -1,32 +1,6 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- # Loads files RRJ and write first message in log,
4
- # then initialize binary
3
+ require 'rrj/rails' if defined?(::Rails::Engine)
5
4
 
6
- require 'rrj/rails' # defined?(::Rails::Engine)
7
- # require File.join(File.dirname(__FILE__), '..', '..', 'binary')
8
-
9
- begin
10
- # bin = RubyRabbitmqJanus::Binary.new
11
- # Log.info \
12
- # 'Prepare to listen events in queue : ' + \
13
- # RubyRabbitmqJanus::Tools::Config.instance.queue_janus_instance
14
- # rabbit = RubyRabbitmqJanus::Rabbit::Connect.new
15
- # rabbit.start
16
- # listener = RubyRabbitmqJanus::Rabbit::Listener::JanusInstance.new(rabbit)
17
- # Log.info 'Loop events provided by Janus queues'
18
- # loop do
19
- # listener.listen_events do |event, response|
20
- # Log.debug "Event : #{event}"
21
- # Log.debug "Response : #{response.to_hash}"
22
- # bin.update_instance(response.to_hash)
23
- # end
24
- # end
25
-
26
- Log.info 'Listen Public queue to Janus'
27
- loop {}
28
- rescue => exception
29
- Log.fatal '!! Fail to start RRJ Thread Janus Instance management !!'
30
- Log.fatal exception
31
- exit 1
32
- end
5
+ Log.info 'Listen Public queue to Janus'
6
+ loop {}
@@ -8,7 +8,6 @@ require 'erb'
8
8
  %w[gem rabbit queues janus].each do |file|
9
9
  require File.join('rrj', 'tools', 'gem', 'config', file)
10
10
  end
11
- # %w[callbacks methods instances validations].each do |file|
12
11
  %w[instances validations].each do |file|
13
12
  require File.join('rrj', 'models', 'concerns', file)
14
13
  end
@@ -9,8 +9,6 @@ describe RubyRabbitmqJanus::Models::JanusInstance, type: :model,
9
9
  {
10
10
  'id' => '_id',
11
11
  'session_id' => 'session',
12
- 'thread_id' => 'thread',
13
- 'thread_id_adm' => 'thread_adm',
14
12
  'instance' => '_id',
15
13
  'title' => 'name'
16
14
  }
@@ -19,8 +17,6 @@ describe RubyRabbitmqJanus::Models::JanusInstance, type: :model,
19
17
  {
20
18
  'instance' => 'id',
21
19
  'session_id' => 'session',
22
- 'thread_id_adm' => 'thread_adm',
23
- 'thread_id' => 'thread',
24
20
  'title' => 'name'
25
21
  }
26
22
  end
@@ -36,7 +36,6 @@ describe RubyRabbitmqJanus::Models::JanusInstance, type: :model,
36
36
 
37
37
  it { expect(model.count).to eq(6) }
38
38
  it { expect(model.enabled.count).to eq(1) }
39
- it { expect(model.find_by_session(one.session).thread).to eq(one.thread) }
40
39
  it { expect(model.find_by_instance(one.instance).session).to eq(one.session) }
41
40
  end
42
41
 
@@ -47,7 +46,6 @@ describe RubyRabbitmqJanus::Models::JanusInstance, type: :model,
47
46
  it { expect(janus.session).to be_nil }
48
47
  it { expect(janus.enable).to be_a(TrueClass) }
49
48
  it { expect(janus.enable).to eq(true) }
50
- it { expect(janus.thread).to be_nil }
51
49
  end
52
50
 
53
51
  context 'when Janus Instance disable' do
@@ -57,6 +55,5 @@ describe RubyRabbitmqJanus::Models::JanusInstance, type: :model,
57
55
  it { expect(janus.session).to be_nil }
58
56
  it { expect(janus.enable).to be_a(FalseClass) }
59
57
  it { expect(janus.enable).to eq(false) }
60
- it { expect(janus.thread).to be_nil }
61
58
  end
62
59
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ruby_rabbitmq_janus
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.7.2.pre.312
4
+ version: 2.7.2.pre.314
5
5
  platform: ruby
6
6
  authors:
7
7
  - VAILLANT Jeremy
@@ -440,7 +440,6 @@ files:
440
440
  - lib/generators/ruby_rabbitmq_janus/templates/initializer.rb
441
441
  - lib/generators/ruby_rabbitmq_janus/templates/migration.rb
442
442
  - lib/rrj/admin.rb
443
- - lib/rrj/binary.rb
444
443
  - lib/rrj/errors/base/admin.rb
445
444
  - lib/rrj/errors/base/base.rb
446
445
  - lib/rrj/errors/base/init.rb
@@ -512,10 +511,6 @@ files:
512
511
  - lib/rrj/process/concurrency.rb
513
512
  - lib/rrj/process/event.rb
514
513
  - lib/rrj/process/event_admin.rb
515
- - lib/rrj/process/keepalive/keepalive_initializer.rb
516
- - lib/rrj/process/keepalive/keepalive_message.rb
517
- - lib/rrj/process/keepalive/keepalive_thread.rb
518
- - lib/rrj/process/keepalive/keepalive_timer.rb
519
514
  - lib/rrj/rabbit/base_event.rb
520
515
  - lib/rrj/rabbit/connect.rb
521
516
  - lib/rrj/rabbit/listener/base.rb
@@ -611,9 +606,6 @@ files:
611
606
  - spec/ruby_rabbitmq_janus/models/janus_instance_definition_spec.rb
612
607
  - spec/ruby_rabbitmq_janus/models/janus_instance_spec.rb
613
608
  - spec/ruby_rabbitmq_janus/process/concurrencies/concurrency_spec.rb
614
- - spec/ruby_rabbitmq_janus/process/concurrencies/keepalive_initializer_spec.rb
615
- - spec/ruby_rabbitmq_janus/process/concurrencies/keepalive_thread_spec.rb
616
- - spec/ruby_rabbitmq_janus/process/concurrencies/keepalive_timer_spec.rb
617
609
  - spec/ruby_rabbitmq_janus/rabbit/connect_spec.rb
618
610
  - spec/ruby_rabbitmq_janus/rabbit/listener/from_spec.rb
619
611
  - spec/ruby_rabbitmq_janus/rabbit/propertie_2_spec.rb
data/lib/rrj/binary.rb DELETED
@@ -1,47 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module RubyRabbitmqJanus
4
- # :reek:InstanceVariableAssumption
5
-
6
- # # RubyRabbitmqJanus Bynary
7
- #
8
- # Initialize tools for a standalone executable
9
- # This class start all tool mandatory for
10
- # survey new message about JanusInstance change state.
11
- #
12
- # When status enable change update document in database
13
- # if enable become true a new session with janus is created
14
- class Binary
15
- def initialize
16
- start_instances
17
- end
18
-
19
- def update_instance(data)
20
- enable = data['enable']
21
- @ji = RubyRabbitmqJanus::Models::JanusInstance.find(data['id'])
22
-
23
- ::Log.info 'Update Janus Instance ...'
24
- enable ? start_instance : stop_instance
25
- end
26
-
27
- private
28
-
29
- def start_instances
30
- ::Log.info 'Search Janus Instance'
31
- instances = RubyRabbitmqJanus::Models::JanusInstance.enabled
32
-
33
- ::Log.info "Find [#{instances.count}] instance(s) enable"
34
- instances.each(&:create_keepalive) unless instances.empty?
35
- end
36
-
37
- def start_instance
38
- ::Log.info "... create a session to Janus Instance with id : #{@ji.id}"
39
- @ji.create_keepalive
40
- end
41
-
42
- def stop_instance
43
- ::Log.info "... stop a session to Janus Instance with ID : #{@ji.id}"
44
- @ji.stop_keepalive
45
- end
46
- end
47
- end
@@ -1,74 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'rrj/process/keepalive/keepalive_timer'
4
- require 'rrj/process/keepalive/keepalive_message'
5
- require 'rrj/process/keepalive/keepalive_thread'
6
-
7
- module RubyRabbitmqJanus
8
- module Process
9
- module Concurrencies
10
- # @author VAILLANT Jeremy <jeremy.vaillant@dazzl.tv>
11
- #
12
- # # Manage keepalive message
13
- #
14
- # Create a thread for sending a message with type keepalive to session
15
- # created by this instanciate gem
16
- class KeepaliveInitializer < Concurrency
17
- # Initialize a singleton object for sending keepalive to janus
18
- def initialize(instance)
19
- super()
20
- @thread = KeepaliveThread.new(instance, rabbit) { initialize_thread }
21
- rescue
22
- raise Errors::Process::KeepaliveInitializer::Initializer
23
- end
24
-
25
- # Get thread with Ruby ID
26
- def self.thread(thread)
27
- ObjectSpace._id2ref(thread)
28
- rescue RangeError
29
- raise Errors::Process::KeepaliveInitializer::ID2Ref, thread
30
- end
31
-
32
- # Give a session Integer his gem is instantiate.
33
- # Is waiting a thread return a response to message created sending.
34
- #
35
- # @example Ask session
36
- # KeepaliveInitializer.new(123).session
37
- # => 852803383803249
38
- #
39
- # @return [Fixnum] Identifier to session created by Janus
40
- def session
41
- @thread.timer.session do
42
- lock.synchronize do
43
- condition.wait(lock)
44
- @thread.session
45
- end
46
- end
47
- rescue
48
- raise Errors::Process::KeepaliveInitializer::Session
49
- end
50
-
51
- # Ask Object ID to thread managing keepalive message
52
- #
53
- # @example Ask ID
54
- # KeepaliveInitializer.new(123).thread
55
- # => 70233080652140
56
- #
57
- # @return [Integer] Identifier to thread in Ruby
58
- def thread_id
59
- @thread.__id__
60
- rescue
61
- raise Errors::Process::KeepaliveInitializer::Thread
62
- end
63
-
64
- private
65
-
66
- def transaction_running
67
- @thread.initialize_janus_session
68
- lock.synchronize { condition.signal }
69
- @thread.start
70
- end
71
- end
72
- end
73
- end
74
- end
@@ -1,57 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # :reek:UtilityFunction
4
-
5
- module RubyRabbitmqJanus
6
- module Process
7
- module Concurrencies
8
- # Manage message used for keepalive thread
9
- #
10
- # @attribute [r] instance
11
- # @return [String] ID to Janus Instance
12
- class KeepaliveMessage
13
- attr_reader :instance
14
-
15
- def initialize(instance)
16
- @instance = instance.id
17
- end
18
-
19
- def session
20
- Janus::Messages::Standard.new('base::create', param_instance)
21
- end
22
-
23
- def response_session(message)
24
- RubyRabbitmqJanus::Janus::Responses::Standard.new(message).session
25
- end
26
-
27
- def keepalive(session)
28
- parameter = param_session(session)
29
- Janus::Messages::Standard.new('base::keepalive', parameter)
30
- end
31
-
32
- def response_acknowledgement(message)
33
- RubyRabbitmqJanus::Janus::Responses::Standard.new(message).error?
34
- end
35
-
36
- def destroy(session)
37
- parameter = param_session(session)
38
- Janus::Messages::Standard.new('base::destroy', parameter)
39
- end
40
-
41
- def response_destroy(message)
42
- RubyRabbitmqJanus::Janus::Responses::Standard.new(message)
43
- end
44
-
45
- private
46
-
47
- def param_instance
48
- { 'instance' => @instance }
49
- end
50
-
51
- def param_session(session)
52
- { 'session_id' => session }.merge(param_instance)
53
- end
54
- end
55
- end
56
- end
57
- end
@@ -1,172 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # rubocop:disable Metrics/ClassLength
4
- # rubocop:disable Metrics/MethodLength
5
-
6
- # :reek:TooManyInstanceVariables
7
- # :reek:TooManyStatements
8
- # :reek:UncommunicativeVariableName
9
- # :reek:TooManyMethods
10
-
11
- module RubyRabbitmqJanus
12
- module Process
13
- module Concurrencies
14
- # Object thread for manage keep a live with Janus Instance
15
- #
16
- # @!attribute [r] session
17
- # @return [Integer] Number to session linked to Janus Instance
18
- class KeepaliveThread < Thread
19
- attr_reader :timer, :session
20
-
21
- def initialize(instance, rabbit, &block)
22
- @publisher = @session = nil
23
- @rabbit = rabbit
24
- @timer = KeepaliveTimer.new
25
- @message = KeepaliveMessage.new(instance)
26
- instance.set(thread: __id__)
27
- ::Log.info "Keepalive thread id is #{__id__}"
28
- super(&block)
29
- rescue
30
- raise Errors::Process::KeepaliveThread::Initializer
31
- end
32
-
33
- # Initialize a transaction with Janus Instance.
34
- # Create a session and save response
35
- def initialize_janus_session
36
- @publisher = publisher
37
- @session = response_session
38
- rescue
39
- raise Errors::Process::KeepaliveThread::InitializeJanusSession
40
- end
41
-
42
- # Restart session
43
- # :reek:TooManyStatements
44
- def restart_session
45
- ::Log.warn 'Restart session ...'
46
- janus = find_model
47
- if janus.present?
48
- send_messages_restart
49
- janus.set(session: @session)
50
- else
51
- ::Log.error 'Janus Instance Model is gone, giving up'
52
- end
53
- rescue
54
- raise Errors::Process::KeepaliveThread::RestartSession
55
- end
56
-
57
- # Start a timer for TTL
58
- # rubocop:disable Metrics/AbcSize
59
- # :reek:TooManyStatements
60
- def start
61
- @timer.loop_keepalive do
62
- if detached?(find_model)
63
- ::Log.info \
64
- "Thread #{__id__} no longer attached to Janus Instance, " \
65
- 'exiting...'
66
- @timer.stop_timer
67
- cleanup
68
- exit
69
- else
70
- ::Log.info msg_send_ttl(__id__,
71
- @message.instance,
72
- @timer.time_to_live)
73
- response_keepalive
74
- end
75
- end
76
- rescue
77
- raise Errors::Process::KeepaliveThread::Start
78
- end
79
- # rubocop:enable Metrics/AbcSize
80
-
81
- # Kill session and disable instance
82
- def kill
83
- cleanup
84
- super
85
- rescue
86
- raise Errors::Process::KeepaliveThread::Kill
87
- end
88
-
89
- # :reek:TooManyStatements
90
- def instance_is_down
91
- janus = find_model
92
- @session = @message = nil
93
- if detached?(janus)
94
- ::Log.error\
95
- "Thread [#{__id__}] no longer attached to Janus Instance " \
96
- '(should be dead).'
97
- else
98
- janus.set(enable: false).unset(%I[thread session])
99
- ::Log.fatal \
100
- "Janus Instance [#{janus.instance}] is down, " \
101
- "thread [#{__id__}] will die."
102
- end
103
- rescue
104
- raise Errors::Process::KeepaliveThread::InstanceIsDown
105
- end
106
-
107
- private
108
-
109
- attr_reader :instance
110
-
111
- def send_messages_restart
112
- @session = response_session
113
- response_keepalive
114
- end
115
-
116
- def cleanup
117
- response_destroy if @session.present? && @message.present?
118
- @rabbit.close
119
- end
120
-
121
- def find_model
122
- if @message.present?
123
- Models::JanusInstance.find(@message.instance)
124
- else
125
- ::Log.warn \
126
- "Lookup Janus Instance model by session [#{@session}]"
127
- Models::JanusInstance.find_by_session(@session)
128
- end
129
- rescue StandardError => exception
130
- ::Log.debug exception
131
- ::Log.warn \
132
- "find_model: rescuing from error #{e.message}"
133
- nil
134
- end
135
-
136
- # :reek:FeatureEnvy
137
- def detached?(janus)
138
- janus.blank? || janus.thread != __id__
139
- end
140
-
141
- def publisher
142
- Rabbit::Publisher::Keepalive.new(@rabbit.channel)
143
- end
144
-
145
- def response_session
146
- @message.response_session(publish(@message.session))
147
- end
148
-
149
- def response_keepalive
150
- keepalive = @message.keepalive(@session)
151
- @message.response_acknowledgement(publish(keepalive))
152
- end
153
-
154
- def response_destroy
155
- destroy = @message.destroy(@session)
156
- @message.response_destroy(publish(destroy))
157
- end
158
-
159
- def publish(message)
160
- @publisher.publish(message)
161
- end
162
-
163
- def msg_send_ttl(id, inst, ttl)
164
- "Thread #{id} sending keepalive to instance #{inst} with TTL #{ttl}"
165
- end
166
- end
167
- end
168
- end
169
- end
170
-
171
- # rubocop:enable Metrics/ClassLength
172
- # rubocop:enable Metrics/MethodLength
@@ -1,77 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'timeout'
4
- require 'timers'
5
-
6
- # :reek:DuplicateMethodCall
7
-
8
- module RubyRabbitmqJanus
9
- module Process
10
- module Concurrencies
11
- # @author VAILLANT Jeremy <jeremy.vaillant@dazzl.tv>
12
- #
13
- # # Manage time for thread
14
- #
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
21
- class KeepaliveTimer
22
- attr_reader :time_to_live, :time_to_die
23
-
24
- # Initialize timer to keeaplive thread.
25
- def initialize
26
- @time_to_live = Tools::Config.instance.ttl
27
- @time_to_die = test_time_to_die >= 60 ? 59 : test_time_to_die
28
- @timers = Timers::Group.new
29
- @timer = nil
30
- rescue
31
- raise Errors::Process::KeepaliveTimer::Initializer
32
- end
33
-
34
- # Execute a loop with timer for sending keepalive message
35
- # to Janus Instance
36
- def loop_keepalive(&block)
37
- @timer = @timers.now_and_every(@time_to_live) { prepare_loop(&block) }
38
- loop { @timers.wait }
39
- rescue
40
- raise Errors::Process::KeepaliveTimer::LoopKeepalive
41
- end
42
-
43
- # Test if session is present/exist in Janus Instance
44
- def session(&block)
45
- Timeout.timeout(@time_to_die) { yield }
46
- rescue Timeout::Error
47
- block.binding.receiver.instance_is_down
48
- rescue
49
- raise Errors::Process::KeepaliveTimer::Session
50
- end
51
-
52
- # Stop timer to keepalive thread
53
- def stop_timer
54
- @timer.cancel
55
- @timer = nil
56
- rescue
57
- raise Errors::Process::KeepaliveTimer::StopTimer
58
- end
59
-
60
- private
61
-
62
- # :reek:FeatureEnvy
63
- def prepare_loop(&block)
64
- Timeout.timeout(@time_to_die) do
65
- block.binding.receiver.restart_session if yield
66
- end
67
- rescue Timeout::Error
68
- block.binding.receiver.instance_is_down
69
- end
70
-
71
- def test_time_to_die
72
- @time_to_live + 5
73
- end
74
- end
75
- end
76
- end
77
- end
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- describe RubyRabbitmqJanus::Process::Concurrencies::KeepaliveInitializer, type: :thread, name: :keepalive_initializer do
6
- let(:instance) { RubyRabbitmqJanus::Models::JanusInstance.find((ENV['MONGO'].match?('true') ? %w[1 2] : [1, 2]).sample) }
7
- let(:concurrency) { described_class.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::Process::Concurrencies::KeepaliveThread) }
13
- end
@@ -1,15 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- describe RubyRabbitmqJanus::Process::Concurrencies::KeepaliveThread, type: :thread, name: :keepalive_thread do
6
- let(:instance) { RubyRabbitmqJanus::Models::JanusInstance.find((ENV['MONGO'].match?('true') ? %w[1 2] : [1, 2]).sample) }
7
- let(:rabbit) { RubyRabbitmqJanus::Process::Concurrencies::Concurrency.new.send(:rabbit) }
8
- let(:concurrency) { described_class.new(instance, rabbit) { nil } }
9
-
10
- it { expect(concurrency.instance_variable_get(:@session)).to be(nil) }
11
- it { expect(concurrency.instance_variable_get(:@publisher)).to be(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::Process::Concurrencies::KeepaliveTimer) }
14
- it { expect(concurrency.instance_variable_get(:@message)).to be_a(RubyRabbitmqJanus::Process::Concurrencies::KeepaliveMessage) }
15
- end
@@ -1,12 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- describe RubyRabbitmqJanus::Process::Concurrencies::KeepaliveTimer, type: :thread, name: :keepalive_timer do
6
- let(:concurrency) { described_class.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(:@timers)).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