ruby_rabbitmq_janus 2.6.0.pre.227 → 2.6.0.pre.228

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
  SHA256:
3
- metadata.gz: eca46c9840cbe7758f93fa8748a4c603dc43dc8db2212ab67a840e97bd3af1f2
4
- data.tar.gz: 3dc04f38427ef4b1e585ccce703ebd2018b1fba570d22498d66720f1448ff548
3
+ metadata.gz: d017c973ed1d038fa82e439709d55676959c39f8d5da0baba11db424871b56ec
4
+ data.tar.gz: 1130ee0bec609d84e3756fceabb59f7b04de788e28eb831c83f6a0efcc7f6d73
5
5
  SHA512:
6
- metadata.gz: c5227e29fbb2d193194182998ac2cbf8988c61a2286108c2d241e2b4057da526c936d20a5d4816c16dfec0b275ce142a665ba1798f4ad0d645560ffda8fc6860
7
- data.tar.gz: 8459d98ede3e7ca8392ef56c3545da0c7c4af6ef979cec3f272626dbeedf90e9a7cd7692a17c80550f6180b575d4b33244d51370adda7c71dfea25d645ae0b82
6
+ metadata.gz: 251050b3b72daf634d10b22559f7b1e54efe53938490a6f4d58069777cc501f0b9648fd4753a4b7e217569bfb9197879b7817e848be6b79fc2b7f30ec7d8c102
7
+ data.tar.gz: 8006626826a1dc238f61551284c8cc9657ee86041f761a4e6bedcaf9f6c827f71567a480ab2afaadd7211c18f0e0cb2f3d9dd33514a63a12f8b0498fb94bfbc8
@@ -7,62 +7,13 @@
7
7
  # a queue in RabbitMQ and enable (or disable) JanusInstance model in database.
8
8
  #
9
9
  # @author VAILLANT Jeremy <jeremy@dazzl.tv>
10
+ # @since 2.6.0
10
11
  #
11
12
  # Use `Log` variable in ActionEvents class
12
13
  # for writing in another logger instead rails logs.
13
14
 
14
- ENVIRONMENT = ENV['RAILS_ENV']
15
- ORM = ENV['ORM']
16
- LISTENER_PATH = ENV['LISTENER_PATH']
17
- PROGRAM = ENV['PROGRAM_NAME']
18
-
19
- begin
20
- require 'config'
21
-
22
- if defined?(Config)
23
- config_conf = [
24
- File.join(Dir.pwd, 'config', 'settings.yml'),
25
- File.join(Dir.pwd, 'config', 'settings', "#{ENVIRONMENT}.yml")
26
- ]
27
- Config.load_and_set_settings(config_conf)
28
- end
29
- rescue LoadError => exception
30
- p 'Don\'t use gem config'
31
- p exception
32
- end
33
-
34
- # Select ORM between Mongoid and ActiveRecord
35
- require ORM
36
- Mongoid.load!(File.join(Dir.pwd, 'config', 'mongoid.yml'), ENVIRONMENT) \
37
- if defined?(Mongoid)
38
- require 'rrj/info'
39
- require 'ruby_rabbitmq_janus'
40
-
41
- ::Log = RubyRabbitmqJanus::Tools::Log.instance
42
-
43
- Log.info "RRJ Version : #{RubyRabbitmqJanus::VERSION}"
44
- Log.info RubyRabbitmqJanus::BANNER
45
-
46
- require File.join(File.dirname(__FILE__), '..', 'lib', 'rrj', 'binary')
47
-
48
- begin
49
- bin = RubyRabbitmqJanus::Binary.new
50
- Log.info \
51
- 'Prepare to listen events in queue : ' + \
52
- RubyRabbitmqJanus::Tools::Config.instance.queue_janus_instance
53
- rabbit = RubyRabbitmqJanus::Rabbit::Connect.new
54
- rabbit.start
55
- listener = RubyRabbitmqJanus::Rabbit::Listener::JanusInstance.new(rabbit)
56
- Log.info 'Loop events provided by Janus queues'
57
- loop do
58
- listener.listen_events do |event, response|
59
- Log.debug "Event : #{event}"
60
- Log.debug "Response : #{response.to_hash}"
61
- bin.update_instance(response.to_hash)
62
- end
63
- end
64
- rescue => exception
65
- Log.fatal '!! Fail to start RRJ threads !!'
66
- Log.fatal exception
67
- exit 1
68
- end
15
+ require 'rrj/tools/bin/environment'
16
+ require 'rrj/tools/bin/arguments'
17
+ require 'rrj/tools/bin/config'
18
+ require 'rrj/tools/bin/model'
19
+ require 'rrj/tools/bin/init'
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Arguments
4
+ #
5
+ # --verbose
6
+ # --log <path>
7
+
8
+ def arg_log(path, class_name)
9
+ @logger_default = false
10
+ @logger_class = class_name
11
+ @logger_path = "#{Dir.pwd}/#{path}"
12
+ end
13
+
14
+ def arg_verbose
15
+ @verbose = true
16
+ end
17
+
18
+ ARGV.each_with_index do |argument, position|
19
+ case argument
20
+ when '--log'
21
+ arg_log(ARGV[position + 1],
22
+ ARGV[position + 2])
23
+ when --'verbose'
24
+ arg_verbose
25
+ else
26
+ next
27
+ end
28
+ end
@@ -0,0 +1,18 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Load gem config if present
4
+
5
+ begin
6
+ require 'config'
7
+
8
+ if defined?(Config)
9
+ config_conf = [
10
+ File.join(Dir.pwd, 'config', 'settings.yml'),
11
+ File.join(Dir.pwd, 'config', 'settings', "#{ENVIRONMENT}.yml")
12
+ ]
13
+ Config.load_and_set_settings(config_conf)
14
+ end
15
+ rescue LoadError => exception
16
+ p 'Don\'t use gem config'
17
+ p exception
18
+ end
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Load environment variables for execute correctly `Binary` class
4
+
5
+ ENVIRONMENT = ENV['RAILS_ENV']
6
+ ORM = ENV['ORM']
7
+ LISTENER_PATH = ENV['LISTENER_PATH']
8
+ PROGRAM = ENV['PROGRAM_NAME']
9
+
10
+ @verbose = false
11
+ @logger_class = true
@@ -0,0 +1,41 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Loads files RRJ and write first message in log,
4
+ # then initialize binary
5
+
6
+ require 'rrj/info'
7
+ require 'ruby_rabbitmq_janus'
8
+
9
+ ::Log = if @logger_default
10
+ RubyRabbitmqJanus::Tools::Log.instance
11
+ else
12
+ require_relative @logger_path
13
+ @logger_class.constantize.instance
14
+ end
15
+
16
+ Log.info "RRJ Version : #{RubyRabbitmqJanus::VERSION}"
17
+ Log.info RubyRabbitmqJanus::BANNER
18
+
19
+ require File.join(File.dirname(__FILE__), '..', '..', 'binary')
20
+
21
+ begin
22
+ bin = RubyRabbitmqJanus::Binary.new
23
+ Log.info \
24
+ 'Prepare to listen events in queue : ' + \
25
+ RubyRabbitmqJanus::Tools::Config.instance.queue_janus_instance
26
+ rabbit = RubyRabbitmqJanus::Rabbit::Connect.new
27
+ rabbit.start
28
+ listener = RubyRabbitmqJanus::Rabbit::Listener::JanusInstance.new(rabbit)
29
+ Log.info 'Loop events provided by Janus queues'
30
+ loop do
31
+ listener.listen_events do |event, response|
32
+ Log.debug "Event : #{event}"
33
+ Log.debug "Response : #{response.to_hash}"
34
+ bin.update_instance(response.to_hash)
35
+ end
36
+ end
37
+ rescue => exception
38
+ Log.fatal '!! Fail to start RRJ threads !!'
39
+ Log.fatal exception
40
+ exit 1
41
+ end
@@ -0,0 +1,7 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Select ORM between Mongoid and ActiveRecord
4
+
5
+ require ORM
6
+ Mongoid.load!(File.join(Dir.pwd, 'config', 'mongoid.yml'), ENVIRONMENT) \
7
+ if defined?(Mongoid)
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.6.0.pre.227
4
+ version: 2.6.0.pre.228
5
5
  platform: ruby
6
6
  authors:
7
7
  - VAILLANT Jeremy
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-07-29 00:00:00.000000000 Z
11
+ date: 2019-07-30 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord
@@ -538,6 +538,11 @@ files:
538
538
  - lib/rrj/railtie.rb
539
539
  - lib/rrj/task.rb
540
540
  - lib/rrj/task_admin.rb
541
+ - lib/rrj/tools/bin/arguments.rb
542
+ - lib/rrj/tools/bin/config.rb
543
+ - lib/rrj/tools/bin/environment.rb
544
+ - lib/rrj/tools/bin/init.rb
545
+ - lib/rrj/tools/bin/model.rb
541
546
  - lib/rrj/tools/gem/cluster.rb
542
547
  - lib/rrj/tools/gem/config.rb
543
548
  - lib/rrj/tools/gem/log.rb