ruby_rabbitmq_janus 2.7.1 → 2.7.2.pre.284

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.
Files changed (47) hide show
  1. checksums.yaml +4 -4
  2. data/config/default.md +0 -1
  3. data/config/default.yml +0 -2
  4. data/lib/rrj/binary.rb +0 -5
  5. data/lib/rrj/errors/error.rb +1 -0
  6. data/lib/rrj/errors/janus/janus.rb +0 -2
  7. data/lib/rrj/errors/{janus/processus → process}/concurency.rb +6 -6
  8. data/lib/rrj/errors/process/event.rb +30 -0
  9. data/lib/rrj/errors/{janus/processus → process}/keepalive/initializer.rb +8 -8
  10. data/lib/rrj/errors/{janus/processus → process}/keepalive/thread.rb +8 -8
  11. data/lib/rrj/errors/{janus/processus → process}/keepalive/timer.rb +6 -6
  12. data/lib/rrj/errors/process/keepalive.rb +21 -0
  13. data/lib/rrj/info.rb +1 -1
  14. data/lib/rrj/janus/janus.rb +0 -1
  15. data/lib/rrj/models/active_record.rb +5 -3
  16. data/lib/rrj/models/concerns/{janus_instance_callbacks.rb → callbacks.rb} +14 -5
  17. data/lib/rrj/models/concerns/{janus_instance_methods.rb → instances.rb} +3 -29
  18. data/lib/rrj/models/concerns/methods.rb +36 -0
  19. data/lib/rrj/models/concerns/{janus_instance_validations.rb → validations.rb} +2 -2
  20. data/lib/rrj/models/mongoid.rb +5 -3
  21. data/lib/rrj/{janus/processus → process}/concurrency.rb +6 -6
  22. data/lib/rrj/{janus/processus → process}/event.rb +3 -3
  23. data/lib/rrj/{janus/processus → process}/event_admin.rb +1 -1
  24. data/lib/rrj/{janus/processus → process}/keepalive/keepalive_initializer.rb +8 -8
  25. data/lib/rrj/{janus/processus → process}/keepalive/keepalive_message.rb +1 -1
  26. data/lib/rrj/{janus/processus → process}/keepalive/keepalive_thread.rb +7 -7
  27. data/lib/rrj/{janus/processus → process}/keepalive/keepalive_timer.rb +5 -5
  28. data/lib/rrj/rabbit/listener/base.rb +4 -11
  29. data/lib/rrj/rails.rb +1 -1
  30. data/lib/rrj/tools/bin/model.rb +0 -1
  31. data/lib/rrj/tools/gem/config/gem.rb +3 -1
  32. data/lib/rrj/tools/gem/config.rb +10 -4
  33. data/lib/rrj/tools/gem/log.rb +2 -1
  34. data/lib/rrj/tools/gem/option.rb +0 -9
  35. data/lib/ruby_rabbitmq_janus.rb +3 -0
  36. data/spec/config/initializer.rb +1 -1
  37. data/spec/factories/janus_instance.rb +1 -1
  38. data/spec/ruby_rabbitmq_janus/models/janus_instance_definition_spec.rb +6 -8
  39. data/spec/ruby_rabbitmq_janus/models/janus_instance_spec.rb +4 -4
  40. data/spec/ruby_rabbitmq_janus/{janus → process}/concurrencies/concurrency_spec.rb +1 -1
  41. data/spec/ruby_rabbitmq_janus/{janus → process}/concurrencies/keepalive_initializer_spec.rb +2 -2
  42. data/spec/ruby_rabbitmq_janus/{janus → process}/concurrencies/keepalive_thread_spec.rb +4 -4
  43. data/spec/ruby_rabbitmq_janus/{janus → process}/concurrencies/keepalive_timer_spec.rb +1 -1
  44. data/spec/spec_helper.rb +8 -10
  45. metadata +34 -41
  46. data/lib/rrj/errors/janus/processus/event.rb +0 -30
  47. data/lib/rrj/errors/janus/processus/keepalive.rb +0 -21
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b13df014ce559c5a7a969efa9c0ab29afa380db71518831692b3613b0c8e55da
4
- data.tar.gz: a69456304e5f8d214da498cb465655af40a23dad988cfe702c9281d83531af62
3
+ metadata.gz: fd2fc20cfe4b8b6b6ed2c6cf7cbb78c40f71f7c2055e8b1d4eb2561fcfcf9b66
4
+ data.tar.gz: edf8c880d0b7e21bb880d7244d2f6a0cf645ee57c2fd68ff1c8fcbe5bbbe567c
5
5
  SHA512:
6
- metadata.gz: 73e4952dd2a8278100e50b07bb33fa6bfb4a3403d0eef2f59c2ec96fe16a976b801f0acb4782d0621b0fdb43ecdf90838ef2a00c01a8259d7fb5f1a60987428c
7
- data.tar.gz: 57e03acba24cf9615011292edf8ffe1c8f994037bafee8bd5ae05f2c568c9366a72927101f9193e257e6adfe11ab892a95c1d8db72966c30e82ea8737d0cfa57
6
+ metadata.gz: 6337c0b68cb0fa09a475e4f0619dc964c52b03876b89275d18f7d55f670e6aaf6ecd86f78855d675f53185f7fa21c2022b810d62cddb3b936c4af19377883cdb
7
+ data.tar.gz: 2ff204e553fdea0d98d2119e616cba6ff4f1271c229f1af78e63e3f6d966a499a8f0ad0c38d712ee1de6ce75d949933953cea17b00cb0d269949b09ad46ceb62
data/config/default.md CHANGED
@@ -40,7 +40,6 @@ gem:
40
40
  path: 'app/ruby_rabbitmq_janus'
41
41
  environment: 'development'
42
42
  orm: 'mongoid'
43
- program_name: 'ruby_rabbitmq_janus'
44
43
  response_path: 'spec/supports/rrj/responses'
45
44
  ```
46
45
 
data/config/default.yml CHANGED
@@ -75,7 +75,5 @@ gem:
75
75
  # Precise ORM used :
76
76
  # mongoid or active_record
77
77
  orm: 'mongoid'
78
- # Define program name
79
- program_name: 'ruby_rabbitmq_janus'
80
78
  # Read response json for RSpec
81
79
  response_path: 'spec/supports/rrj/responses'
data/lib/rrj/binary.rb CHANGED
@@ -1,10 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'rrj/models/concerns/janus_instance_callbacks'
4
- require 'rrj/models/concerns/janus_instance_methods'
5
- require 'rrj/models/concerns/janus_instance_validations'
6
- require "rrj/models/#{RubyRabbitmqJanus::Tools::Config.instance.orm}"
7
-
8
3
  module RubyRabbitmqJanus
9
4
  # :reek:InstanceVariableAssumption
10
5
 
@@ -31,5 +31,6 @@ end
31
31
 
32
32
  require 'rrj/errors/base/base'
33
33
  require 'rrj/errors/janus/janus'
34
+ require 'rrj/errors/process/concurency'
34
35
  require 'rrj/errors/tools/tools'
35
36
  require 'rrj/errors/rabbit/rabbit'
@@ -16,8 +16,6 @@ module RubyRabbitmqJanus
16
16
  end
17
17
  end
18
18
 
19
- require 'rrj/errors/janus/processus/concurency'
20
-
21
19
  require 'rrj/errors/janus/messages/message'
22
20
  require 'rrj/errors/janus/messages/admin'
23
21
  require 'rrj/errors/janus/messages/standard'
@@ -2,8 +2,8 @@
2
2
 
3
3
  module RubyRabbitmqJanus
4
4
  module Errors
5
- module Janus
6
- # Define a super class for all error in Janus::Concurency class
5
+ module Process
6
+ # Define a super class for all error in Process::Concurency class
7
7
  class BaseConcurency < RubyRabbitmqJanus::Errors::BaseJanus
8
8
  def initialize(message)
9
9
  super "[Concurency]#{message}", :fatal
@@ -11,8 +11,8 @@ module RubyRabbitmqJanus
11
11
  end
12
12
 
13
13
  module Concurency
14
- # Error for Janus::Concurency#initialize
15
- class Initializer < RubyRabbitmqJanus::Errors::Janus::BaseConcurency
14
+ # Error for Process::Concurency#initialize
15
+ class Initializer < RubyRabbitmqJanus::Errors::Process::BaseConcurency
16
16
  def initialize
17
17
  super 'Error initialize concurency class'
18
18
  end
@@ -22,5 +22,5 @@ module RubyRabbitmqJanus
22
22
  end
23
23
  end
24
24
 
25
- require 'rrj/errors/janus/processus/keepalive'
26
- require 'rrj/errors/janus/processus/event'
25
+ require 'rrj/errors/process/keepalive'
26
+ require 'rrj/errors/process/event'
@@ -0,0 +1,30 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RubyRabbitmqJanus
4
+ module Errors
5
+ module Process
6
+ # Define a super class for all error in Process::Concurency::Event class
7
+ class BaseEvent < RubyRabbitmqJanus::Errors::Process::BaseConcurency
8
+ def initialize(message)
9
+ super "[Event] #{message}"
10
+ end
11
+ end
12
+
13
+ module Event
14
+ # Error for Process::Concurency::Event#initialize
15
+ class Initializer < RubyRabbitmqJanus::Errors::Process::BaseEvent
16
+ def initializer
17
+ super 'Error Event initializer'
18
+ end
19
+ end
20
+
21
+ # Error for Process::Concurency::Event#run
22
+ class Run < RubyRabbitmqJanus::Errors::Process::BaseEvent
23
+ def initializer
24
+ super 'Error running block code'
25
+ end
26
+ end
27
+ end
28
+ end
29
+ end
30
+ end
@@ -4,7 +4,7 @@
4
4
 
5
5
  module RubyRabbitmqJanus
6
6
  module Errors
7
- module Janus
7
+ module Process
8
8
  class BaseKeepaliveInitializer < BaseKeepalive
9
9
  def initialize(message)
10
10
  super "[Initializer] #{message}"
@@ -12,43 +12,43 @@ module RubyRabbitmqJanus
12
12
  end
13
13
 
14
14
  module KeepaliveInitializer
15
- class Initializer < RubyRabbitmqJanus::Errors::Janus::BaseKeepaliveInitializer
15
+ class Initializer < RubyRabbitmqJanus::Errors::Process::BaseKeepaliveInitializer
16
16
  def initialize
17
17
  super 'Error keepalive initializer'
18
18
  end
19
19
  end
20
20
 
21
- class ID2ref < RubyRabbitmqJanus::Errors::Janus::BaseKeepaliveInitializer
21
+ class ID2ref < RubyRabbitmqJanus::Errors::Process::BaseKeepaliveInitializer
22
22
  def initialize(thread_id)
23
23
  super "No thread with ID : #{thread_id}"
24
24
  end
25
25
  end
26
26
 
27
- class Session < RubyRabbitmqJanus::Errors::Janus::BaseKeepaliveInitializer
27
+ class Session < RubyRabbitmqJanus::Errors::Process::BaseKeepaliveInitializer
28
28
  def initialize
29
29
  super 'Error return session number'
30
30
  end
31
31
  end
32
32
 
33
- class Thread < RubyRabbitmqJanus::Errors::Janus::BaseKeepaliveInitializer
33
+ class Thread < RubyRabbitmqJanus::Errors::Process::BaseKeepaliveInitializer
34
34
  def initialize
35
35
  super 'Error for get Object Thread ID'
36
36
  end
37
37
  end
38
38
 
39
- class ThreadStart < RubyRabbitmqJanus::Errors::Janus::BaseKeepaliveInitializer
39
+ class ThreadStart < RubyRabbitmqJanus::Errors::Process::BaseKeepaliveInitializer
40
40
  def initialize
41
41
  super 'Error for starting timer in thread'
42
42
  end
43
43
  end
44
44
 
45
- class ThreadStop < RubyRabbitmqJanus::Errors::Janus::BaseKeepaliveInitializer
45
+ class ThreadStop < RubyRabbitmqJanus::Errors::Process::BaseKeepaliveInitializer
46
46
  def initialize
47
47
  super 'Error for stoping timer in thread'
48
48
  end
49
49
  end
50
50
 
51
- class ThreadDelete < RubyRabbitmqJanus::Errors::Janus::BaseKeepaliveInitializer
51
+ class ThreadDelete < RubyRabbitmqJanus::Errors::Process::BaseKeepaliveInitializer
52
52
  def initialize
53
53
  super 'Error for destroy thread'
54
54
  end
@@ -4,8 +4,8 @@
4
4
 
5
5
  module RubyRabbitmqJanus
6
6
  module Errors
7
- module Janus
8
- # Define a super class for all error in Janus::Concurency::Keepalive
7
+ module Process
8
+ # Define a super class for all error in Process::Concurency::Keepalive
9
9
  class BaseKeepaliveThread < BaseKeepalive
10
10
  def initialize(message)
11
11
  super "[Thread] #{message}"
@@ -13,37 +13,37 @@ module RubyRabbitmqJanus
13
13
  end
14
14
 
15
15
  module KeepaliveThread
16
- class Initializer < RubyRabbitmqJanus::Errors::Janus::BaseKeepaliveThread
16
+ class Initializer < RubyRabbitmqJanus::Errors::Process::BaseKeepaliveThread
17
17
  def initialize
18
18
  super 'Error for initialize Keepalive Thread'
19
19
  end
20
20
  end
21
21
 
22
- class InitializeJanusSession < RubyRabbitmqJanus::Errors::Janus::BaseKeepaliveThread
22
+ class InitializeJanusSession < RubyRabbitmqJanus::Errors::Process::BaseKeepaliveThread
23
23
  def initialize
24
24
  super 'Error when initialize message in keepalive thread'
25
25
  end
26
26
  end
27
27
 
28
- class RestartSession < RubyRabbitmqJanus::Errors::Janus::BaseKeepaliveThread
28
+ class RestartSession < RubyRabbitmqJanus::Errors::Process::BaseKeepaliveThread
29
29
  def initialize
30
30
  super 'Error when restart session'
31
31
  end
32
32
  end
33
33
 
34
- class Start < RubyRabbitmqJanus::Errors::Janus::BaseKeepaliveThread
34
+ class Start < RubyRabbitmqJanus::Errors::Process::BaseKeepaliveThread
35
35
  def initialize
36
36
  super 'Error when start a loop for sending keepalive message'
37
37
  end
38
38
  end
39
39
 
40
- class Kill < RubyRabbitmqJanus::Errors::Janus::BaseKeepaliveThread
40
+ class Kill < RubyRabbitmqJanus::Errors::Process::BaseKeepaliveThread
41
41
  def initialize
42
42
  super 'Error when killing thread'
43
43
  end
44
44
  end
45
45
 
46
- class InstanceIsDown < RubyRabbitmqJanus::Errors::Janus::BaseKeepaliveThread
46
+ class InstanceIsDown < RubyRabbitmqJanus::Errors::Process::BaseKeepaliveThread
47
47
  def initialize
48
48
  super 'Error when instance is down'
49
49
  end
@@ -4,7 +4,7 @@
4
4
 
5
5
  module RubyRabbitmqJanus
6
6
  module Errors
7
- module Janus
7
+ module Process
8
8
  class BaseKeepaliveTimer < BaseKeepalive
9
9
  def initialize(message)
10
10
  super "[Timer] #{message}"
@@ -12,31 +12,31 @@ module RubyRabbitmqJanus
12
12
  end
13
13
 
14
14
  module KeepaliveTimer
15
- class Initializer < RubyRabbitmqJanus::Errors::Janus::BaseKeepaliveTimer
15
+ class Initializer < RubyRabbitmqJanus::Errors::Process::BaseKeepaliveTimer
16
16
  def initialize
17
17
  super 'Error for initialize Keepalive Timer'
18
18
  end
19
19
  end
20
20
 
21
- class LoopKeepalive < RubyRabbitmqJanus::Errors::Janus::BaseKeepaliveTimer
21
+ class LoopKeepalive < RubyRabbitmqJanus::Errors::Process::BaseKeepaliveTimer
22
22
  def initialize
23
23
  super 'Loop for create timer in Keepalive Thread is failed'
24
24
  end
25
25
  end
26
26
 
27
- class Session < RubyRabbitmqJanus::Errors::Janus::BaseKeepaliveTimer
27
+ class Session < RubyRabbitmqJanus::Errors::Process::BaseKeepaliveTimer
28
28
  def initialize
29
29
  super 'Timeout for get session number in keepalive request'
30
30
  end
31
31
  end
32
32
 
33
- class StopTimer < RubyRabbitmqJanus::Errors::Janus::BaseKeepaliveTimer
33
+ class StopTimer < RubyRabbitmqJanus::Errors::Process::BaseKeepaliveTimer
34
34
  def initialize
35
35
  super 'Error when timer to Keepalive Thread stop'
36
36
  end
37
37
  end
38
38
 
39
- class StartTimer < RubyRabbitmqJanus::Errors::Janus::BaseKeepaliveTimer
39
+ class StartTimer < RubyRabbitmqJanus::Errors::Process::BaseKeepaliveTimer
40
40
  def initialize
41
41
  super 'Error when timer to Keepalive Thread start'
42
42
  end
@@ -0,0 +1,21 @@
1
+ # frozen_string_literal: true
2
+
3
+ # @author VAILLANT Jeremy <jeremy.vaillant@dazzl.tv>
4
+ # @see RubyRabbitmqJanus::Janus::Keepalive Keepalive thread
5
+
6
+ module RubyRabbitmqJanus
7
+ module Errors
8
+ module Process
9
+ # Define a super class for all error in Process::Concurency::Keepalive
10
+ class BaseKeepalive < RubyRabbitmqJanus::Errors::Process::BaseConcurency
11
+ def initialize(message)
12
+ super "[Keepalive]#{message}"
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
18
+
19
+ require 'rrj/errors/process/keepalive/initializer'
20
+ require 'rrj/errors/process/keepalive/thread'
21
+ require 'rrj/errors/process/keepalive/timer'
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.7.1'
9
+ VERSION = '2.7.2'
10
10
 
11
11
  # Name to gem
12
12
  GEM_NAME = 'ruby_rabbitmq_janus'
@@ -1,6 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'rrj/janus/processus/concurrency'
4
3
  require 'rrj/janus/messages/message'
5
4
  require 'rrj/janus/responses/response'
6
5
  require 'rrj/janus/transactions/transaction'
@@ -8,13 +8,15 @@ module RubyRabbitmqJanus
8
8
  #
9
9
  # Store instance information for MongoID database
10
10
  class JanusInstance < ::ActiveRecord::Base
11
- include RubyRabbitmqJanus::Models::JanusInstanceCallbacks
12
- include RubyRabbitmqJanus::Models::JanusInstanceMethods
13
- include RubyRabbitmqJanus::Models::JanusInstanceValidations
11
+ include RubyRabbitmqJanus::Models::Instances
12
+ include RubyRabbitmqJanus::Models::Methods
13
+ include RubyRabbitmqJanus::Models::Callbacks
14
+ include RubyRabbitmqJanus::Models::Validations
14
15
 
15
16
  self.primary_key = :id
16
17
 
17
18
  alias_attribute :instance, :id
19
+ alias_attribute :title, :name
18
20
  alias_attribute :session_id, :session
19
21
  alias_attribute :thread_id, :thread
20
22
  alias_attribute :thread_id_adm, :thread_adm
@@ -4,19 +4,19 @@ module RubyRabbitmqJanus
4
4
  # Contains all model for this gem
5
5
  module Models
6
6
  # Configure callback for Janus Instance models
7
- module JanusInstanceCallbacks
7
+ module Callbacks
8
8
  extend ActiveSupport::Concern
9
9
 
10
10
  # Create a session in Janus Instance
11
11
  def callback_create_after
12
- ::Log.debug 'Callback AFTER_VALIDATION'
12
+ ::Log.debug '[JanusInstance] Callback AFTER_VALIDATION'
13
13
  create_a_session_in_janus_instance if enable
14
14
  end
15
15
 
16
16
  # Update a keepalive transaction in Janus Instance
17
17
  # Enable or Disable transaction
18
18
  def callback_update_after
19
- ::Log.debug 'Callback AFTER_UPDATE'
19
+ ::Log.debug '[JanusInstance] Callback AFTER_UPDATE'
20
20
  if enable && enable_changed?
21
21
  create_a_session_in_janus_instance
22
22
  elsif !enable && enable_changed?
@@ -27,22 +27,31 @@ module RubyRabbitmqJanus
27
27
  # Destroy a session in Janus Instance
28
28
  # :reek:UtilityFunction
29
29
  def callback_destroy_after
30
- ::Log.debug 'Callback AFTER_DESTROY'
30
+ ::Log.debug '[JanusInstance] Callback AFTER_DESTROY'
31
31
  # LCO: nothing to do, thread will close session and die
32
32
  end
33
33
 
34
34
  private
35
35
 
36
36
  def create_a_session_in_janus_instance
37
+ ::Log.debug '[JanusInstance] Create session'
37
38
  RubyRabbitmqJanus::Rabbit::Publisher::JanusInstance.new.publish(message)
38
39
  end
39
40
 
40
41
  def destroy_a_session_in_janus_instance
42
+ ::Log.debug '[JanusInstance] Destroy session'
41
43
  RubyRabbitmqJanus::Rabbit::Publisher::JanusInstance.new.publish(message)
44
+
45
+ ::Log.debug '[JanusInstance] Kill thread'
46
+ thread_object.kill if thread_object.alive?
47
+ end
48
+
49
+ def thread_object
50
+ ObjectSpace._id2ref(thread)
42
51
  end
43
52
 
44
53
  def keepalive_object
45
- RubyRabbitmqJanus::Janus::Concurrencies::KeepaliveInitializer
54
+ RubyRabbitmqJanus::Process::Concurrencies::KeepaliveInitializer
46
55
  end
47
56
 
48
57
  def keepalive_object_new
@@ -4,11 +4,11 @@
4
4
 
5
5
  module RubyRabbitmqJanus
6
6
  module Models
7
- # Add method for JanusInstance model
8
- module JanusInstanceMethods
7
+ # Add class methods for JanusInstance model
8
+ module Instances
9
9
  extend ActiveSupport::Concern
10
10
 
11
- # Class methods for JanusInstance model
11
+ # Class methods for Janus Instance model
12
12
  module ClassMethods
13
13
  # Disable an instance
14
14
  def disable(session_id)
@@ -44,32 +44,6 @@ module RubyRabbitmqJanus
44
44
  JanusInstance.where(enable: false)
45
45
  end
46
46
  end
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
-
60
- private
61
-
62
- def search_initializer(options)
63
- if File.basename($PROGRAM_NAME) == 'rake'
64
- ::RRJ.start_transaction(options) do |transaction|
65
- yield(transaction)
66
- end
67
- else
68
- ::RRJ.start_transaction(true, options) do |transaction|
69
- yield(transaction)
70
- end
71
- end
72
- end
73
47
  end
74
48
  end
75
49
  end
@@ -0,0 +1,36 @@
1
+ # frozen_string_literal: true
2
+
3
+ module RubyRabbitmqJanus
4
+ module Models
5
+ # Add method for Janus Instance model
6
+ module Methods
7
+ extend ActiveSupport::Concern
8
+
9
+ # Create thread keepalive
10
+ def create_keepalive
11
+ ::Log.info 'Create session'
12
+ janus_instance = keepalive_object_new
13
+ set(session: janus_instance.session, enable: true)
14
+ end
15
+
16
+ # Stop thread keepalive
17
+ def stop_keepalive
18
+ ::Log.info 'Destroy session'
19
+ unset(%I[thread thread_adm session])
20
+ set(enable: false)
21
+ end
22
+
23
+ # Start Janus instance
24
+ # @since 2.7.1
25
+ def start!
26
+ update(enable: true)
27
+ end
28
+
29
+ # Stop Janus instance
30
+ # @since 2.7.1
31
+ def stop!
32
+ update(enable: false)
33
+ end
34
+ end
35
+ end
36
+ end
@@ -2,8 +2,8 @@
2
2
 
3
3
  module RubyRabbitmqJanus
4
4
  module Models
5
- # Configure validation for JanusInstance model
6
- module JanusInstanceValidations
5
+ # Configure validation for Janus Instance model
6
+ module Validations
7
7
  extend ActiveSupport::Concern
8
8
 
9
9
  included do
@@ -7,10 +7,12 @@ module RubyRabbitmqJanus
7
7
  # Store instance information for MongoID database
8
8
  class JanusInstance
9
9
  include Mongoid::Document
10
- include RubyRabbitmqJanus::Models::JanusInstanceCallbacks
11
- include RubyRabbitmqJanus::Models::JanusInstanceMethods
12
- include RubyRabbitmqJanus::Models::JanusInstanceValidations
10
+ include RubyRabbitmqJanus::Models::Instances
11
+ include RubyRabbitmqJanus::Models::Methods
12
+ include RubyRabbitmqJanus::Models::Callbacks
13
+ include RubyRabbitmqJanus::Models::Validations
13
14
 
15
+ field :name, type: String, as: :title
14
16
  field :session, type: Integer, as: :session_id
15
17
  field :enable, type: Boolean
16
18
  field :thread, type: Integer, as: :thread_id
@@ -1,8 +1,8 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RubyRabbitmqJanus
4
- module Janus
5
- # Modules for create autonomous processus
4
+ module Process
5
+ # Modules for create autonomous process
6
6
  module Concurrencies
7
7
  # @author VAILLANT Jeremy <jeremy.vaillant@dazzl.tv>
8
8
  #
@@ -18,7 +18,7 @@ module RubyRabbitmqJanus
18
18
  @lock = Mutex.new
19
19
  @condition = ConditionVariable.new
20
20
  rescue
21
- raise Errors::Janus::Concurencies::Initializer
21
+ raise Errors::Process::Concurencies::Initializer
22
22
  end
23
23
 
24
24
  private
@@ -40,6 +40,6 @@ module RubyRabbitmqJanus
40
40
  end
41
41
  end
42
42
 
43
- require 'rrj/janus/processus/keepalive/keepalive_initializer'
44
- require 'rrj/janus/processus/event'
45
- require 'rrj/janus/processus/event_admin'
43
+ require 'rrj/process/keepalive/keepalive_initializer'
44
+ require 'rrj/process/event'
45
+ require 'rrj/process/event_admin'
@@ -1,7 +1,7 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module RubyRabbitmqJanus
4
- module Janus
4
+ module Process
5
5
  module Concurrencies
6
6
  # @author VAILLANT Jeremy <jeremy.vaillant@dazzl.tv>
7
7
 
@@ -20,7 +20,7 @@ module RubyRabbitmqJanus
20
20
  super
21
21
  @thread = Thread.new { initialize_thread }
22
22
  rescue
23
- raise Errors::Janus::Event::Initializer
23
+ raise Errors::Process::Event::Initializer
24
24
  end
25
25
 
26
26
  # Create a thread for execute a block code in a thread
@@ -38,7 +38,7 @@ module RubyRabbitmqJanus
38
38
  end
39
39
  end
40
40
  rescue
41
- raise Errors::Janus::Event::Run
41
+ raise Errors::Process::Event::Run
42
42
  end
43
43
 
44
44
  private
@@ -3,7 +3,7 @@
3
3
  # :reek:InstanceVariableAssumption
4
4
 
5
5
  module RubyRabbitmqJanus
6
- module Janus
6
+ module Process
7
7
  module Concurrencies
8
8
  # Manage admin message in queue public
9
9
  # Work In Progress
@@ -1,11 +1,11 @@
1
1
  # frozen_string_literal: true
2
2
 
3
- require 'rrj/janus/processus/keepalive/keepalive_timer'
4
- require 'rrj/janus/processus/keepalive/keepalive_message'
5
- require 'rrj/janus/processus/keepalive/keepalive_thread'
3
+ require 'rrj/process/keepalive/keepalive_timer'
4
+ require 'rrj/process/keepalive/keepalive_message'
5
+ require 'rrj/process/keepalive/keepalive_thread'
6
6
 
7
7
  module RubyRabbitmqJanus
8
- module Janus
8
+ module Process
9
9
  module Concurrencies
10
10
  # @author VAILLANT Jeremy <jeremy.vaillant@dazzl.tv>
11
11
  #
@@ -19,14 +19,14 @@ module RubyRabbitmqJanus
19
19
  super()
20
20
  @thread = KeepaliveThread.new(instance, rabbit) { initialize_thread }
21
21
  rescue
22
- raise Errors::Janus::KeepaliveInitializer::Initializer
22
+ raise Errors::Process::KeepaliveInitializer::Initializer
23
23
  end
24
24
 
25
25
  # Get thread with Ruby ID
26
26
  def self.thread(thread)
27
27
  ObjectSpace._id2ref(thread)
28
28
  rescue RangeError
29
- raise Errors::Janus::KeepaliveInitializer::ID2Ref, thread
29
+ raise Errors::Process::KeepaliveInitializer::ID2Ref, thread
30
30
  end
31
31
 
32
32
  # Give a session Integer his gem is instantiate.
@@ -45,7 +45,7 @@ module RubyRabbitmqJanus
45
45
  end
46
46
  end
47
47
  rescue
48
- raise Errors::Janus::KeepaliveInitializer::Session
48
+ raise Errors::Process::KeepaliveInitializer::Session
49
49
  end
50
50
 
51
51
  # Ask Object ID to thread managing keepalive message
@@ -58,7 +58,7 @@ module RubyRabbitmqJanus
58
58
  def thread_id
59
59
  @thread.__id__
60
60
  rescue
61
- raise Errors::Janus::KeepaliveInitializer::Thread
61
+ raise Errors::Process::KeepaliveInitializer::Thread
62
62
  end
63
63
 
64
64
  private
@@ -3,7 +3,7 @@
3
3
  # :reek:UtilityFunction
4
4
 
5
5
  module RubyRabbitmqJanus
6
- module Janus
6
+ module Process
7
7
  module Concurrencies
8
8
  # Manage message used for keepalive thread
9
9
  #