ruby_rabbitmq_janus 2.1.0.pre.132 → 2.1.0.pre.135

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: da7e01aeca98c6e18831e2cf501e64dc610b475d
4
- data.tar.gz: c4360ad19e7e7b6c4d8f889a1d129a4e6054d075
3
+ metadata.gz: c188ceac4ac4583890417754fd3e2c26fcdb234e
4
+ data.tar.gz: 9d7c46b66b1a3df6af9ff38057182c570a29e0e4
5
5
  SHA512:
6
- metadata.gz: bf48a1a06651cfd5ffbe2efe96ce432ffdaf2a08c45dd41f90f415d20fab6ec74219d7df6cdf0634b51171665c0ecfb753d8f8dca014672e6072c7e08d80e3b7
7
- data.tar.gz: aabb11904efe47062cfe789ade7ef8f2cf332f48be8cf69cea9785213d4d14315e3622d518aded39be036bf175628d4ea967b2b69c3ed75ebf6a6334652625ad
6
+ metadata.gz: e029d096e54440d38d4b5a4da95adae672d2ffdd515aecdcfd18c5ee79e408bb898dbff38f8d44360ae38f2eddeb6ba13adb982f67cd684a28faa0d8581fdf3c
7
+ data.tar.gz: ced541b0b09c60aa4175c1d6936f934b8ad8708d6709321227ae2a1f5cc775d65fa4daa522ada37727064faaed98d11aac2ab5d15adf32dfa2925f41b8766346
data/config/default.md CHANGED
@@ -12,6 +12,7 @@ rabbit:
12
12
  user: guest
13
13
  pass: guest
14
14
  admin_pass: janusoverlord
15
+ level: :info
15
16
 
16
17
  queues:
17
18
  standard:
data/config/default.yml CHANGED
@@ -10,8 +10,10 @@ rabbit:
10
10
  user: guest
11
11
  # Precise RabbitMQ password - Default 'guest'
12
12
  pass: guest
13
- # Password for admin request
13
+ # Password for admin request
14
14
  admin_pass: janusoverlord
15
+ # Logger level for rabbitmq message
16
+ level: info
15
17
 
16
18
  # RabbitMQ Queue information
17
19
  queues:
data/config/requests.md CHANGED
@@ -21,6 +21,7 @@ By default this gem contains many request :
21
21
  │   ├── answer.json
22
22
  │   ├── offer.json
23
23
  │   ├── trickle.json
24
+ │   ├── trickles.json
24
25
  ```
25
26
 
26
27
  * Folder `admin` contains admin requests for interact with Janus Admin/Monitor
@@ -55,6 +55,13 @@ module RubyRabbitmqJanus
55
55
  end
56
56
  end
57
57
 
58
+ # Error for Tools::Config#log_level
59
+ class LevelRabbitMissing < RubyRabbitmqJanus::Errors::Tools::BaseConfig
60
+ def initialize
61
+ super 'Error for reading option level for rabbitmq', :warn
62
+ end
63
+ end
64
+
58
65
  # Error for Tools::Config#time_to_live (or #ttl)
59
66
  class TTLNotFound < RubyRabbitmqJanus::Errors::Tools::BaseConfig
60
67
  def initialize
data/lib/rrj/init.rb CHANGED
@@ -39,7 +39,9 @@ module RubyRabbitmqJanus
39
39
  # => #<RubyRabbitmqJanus::RRJ:0x007 @session=123>
40
40
  def initialize
41
41
  @option = Tools::Option.new
42
- ObjectSpace.define_finalizer(self, RRJ.method(:delete).to_proc)
42
+ puts "Base Program : #{$PROGRAM_NAME}"
43
+ ObjectSpace.define_finalizer(self, RRJ.method(:delete).to_proc) \
44
+ unless File.basename($PROGRAM_NAME).eql?('rspec')
43
45
  rescue => error
44
46
  raise Errors::RRJ::InstanciateGem, error
45
47
  end
@@ -72,12 +72,9 @@ module RubyRabbitmqJanus
72
72
  private
73
73
 
74
74
  def create_handle
75
- Tools::Log.instance.info 'Create an handle'
76
75
  opt = { 'session_id' => session, 'instance' => @instance }
77
76
  msg = Janus::Messages::Standard.new('base::attach', opt)
78
- Tools::Log.instance.info "Send message attach -- #{@handle}"
79
77
  @handle = send_a_message_exclusive { msg }
80
- Tools::Log.instance.info "Message attach is sending -- #{@handle}"
81
78
  end
82
79
 
83
80
  def send_a_message_exclusive
@@ -63,14 +63,10 @@ module RubyRabbitmqJanus
63
63
  end
64
64
 
65
65
  def option_log_rabbit
66
- if Tools::Log.instance.level.zero?
67
- {
68
- log_level: Tools::Log.instance.level,
69
- log_file: Tools::Log.instance.logdev
70
- }
71
- else
72
- {}
73
- end
66
+ {
67
+ log_level: Tools::Config.instance.log_level_rabbit,
68
+ log_file: Tools::Log.instance.logdev
69
+ }
74
70
  end
75
71
  end
76
72
  end
data/lib/rrj/task.rb CHANGED
@@ -40,12 +40,21 @@ module RubyRabbitmqJanus
40
40
  #
41
41
  # @since 2.1.0
42
42
  def start_transaction_handle(exclusive = true, options = {})
43
- session = Models::JanusInstance.find_by(options['instance']).session
43
+ janus = session_instance(options)
44
44
  handle = 0 # Create always a new handle
45
- transaction = Janus::Transactions::Handle.new(exclusive, session, handle)
45
+ transaction = Janus::Transactions::Handle.new(exclusive,
46
+ janus.session,
47
+ handle,
48
+ janus.instance)
46
49
  transaction.connect { yield(transaction) }
47
50
  rescue
48
51
  raise Errors::RRJTask::StartTransactionHandle, exclusive, options
49
52
  end
53
+
54
+ private
55
+
56
+ def session_instance(options)
57
+ Models::JanusInstance.find_by_instance(options['instance'])
58
+ end
50
59
  end
51
60
  end
@@ -77,7 +77,13 @@ module RubyRabbitmqJanus
77
77
 
78
78
  # @return [Symbol] read configuration for log level used in this gem
79
79
  def log_level
80
- @options['gem']['log']['level'].upcase.to_sym
80
+ @options['gem']['log']['level'].upcase.to_sym || :INFO
81
+ rescue
82
+ raise Errors::Tools::Config::LevelNotDefine
83
+ end
84
+
85
+ def log_level_rabbit
86
+ @options['rabbit']['level'].upcase.to_sym || :INFO
81
87
  rescue
82
88
  raise Errors::Tools::Config::LevelNotDefine
83
89
  end
@@ -4,11 +4,14 @@ namespace :rrj do
4
4
  namespace :delete do
5
5
  desc 'Delete all instances in database and janus'
6
6
  task all_instances: :environment do
7
+ tags = '[RubyRabbitmqJanus][rrj:delete:all_instances] '
7
8
  timelaps = Time.now.utc
8
9
 
10
+ Rails.logger.info "#{tags}Delete all instances"
11
+
9
12
  RubyRabbitmqJanus::Models::JanusInstance.destroy_all
10
13
 
11
- Rails.logger.info "Executed in #{Time.now.utc - timelaps} ms"
14
+ Rails.logger.info "#{tags}Executed in #{Time.now.utc - timelaps} ms"
12
15
  end
13
16
  end
14
17
  end
@@ -4,17 +4,18 @@ namespace :rrj do
4
4
  namespace :delete do
5
5
  desc 'Delete one instance in database and janus'
6
6
  task :one_instance, [:instance, :session] => :environment do |_task, args|
7
+ tags = '[RubyRabbitmqJanus][rrj:delete:one_instance] '
7
8
  timelaps = Time.now.utc
8
9
 
9
- Rails.logger.info \
10
- "Delete instance #{args[:instance]} with session #{args[:session]}"
10
+ Rails.logger.info "#{tags}Delete instance #{args[:instance]} " \
11
+ "with session #{args[:session]}"
11
12
 
12
13
  janus_instance = RubyRabbitmqJanus::Models::JanusInstance\
13
14
  .find_by_session(args[:session])
14
15
 
15
16
  janus_instance.destroy if janus_instance
16
17
 
17
- Rails.logger.info "Executed in #{Time.now.utc - timelaps} ms"
18
+ Rails.logger.info "#{tags}Executed in #{Time.now.utc - timelaps} ms"
18
19
  end
19
20
  end
20
21
  end
@@ -4,11 +4,14 @@ namespace :rrj do
4
4
  namespace :delete do
5
5
  desc 'Delete all instances disable in database and janus'
6
6
  task unless_instance: :environment do
7
+ tags = '[RubyRabbitmqJanus][rrj:delete:unless_instance] '
7
8
  timelaps = Time.now.utc
8
9
 
10
+ Rails.logger.info "#{tags}Delete unless instance(s)"
11
+
9
12
  RubyRabbitmqJanus::Models::JanusInstance.find_by(enable: false).delete_all
10
13
 
11
- Rails.logger.info "Executed in #{Time.now.utc - timelaps} ms"
14
+ Rails.logger.info "#{tags}Executed in #{Time.now.utc - timelaps} ms"
12
15
  end
13
16
  end
14
17
  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.1.0.pre.132
4
+ version: 2.1.0.pre.135
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-06-09 00:00:00.000000000 Z
11
+ date: 2017-06-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler