ruby_rabbitmq_janus 2.0.0 → 2.1.0.pre.128

Sign up to get free protection for your applications and to get access to all the features.
Files changed (115) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +14 -3
  3. data/Rakefile +98 -0
  4. data/config/default.md +6 -3
  5. data/config/default.yml +7 -1
  6. data/lib/generators/ruby_rabbitmq_janus/install_generator.rb +3 -0
  7. data/lib/generators/ruby_rabbitmq_janus/migration_generator.rb +30 -0
  8. data/lib/generators/ruby_rabbitmq_janus/templates/migration.rb +14 -0
  9. data/lib/rrj/admin.rb +2 -0
  10. data/lib/rrj/errors/base/admin.rb +24 -0
  11. data/lib/rrj/errors/base/base.rb +5 -0
  12. data/lib/rrj/errors/base/init.rb +46 -0
  13. data/lib/rrj/errors/base/task.rb +32 -0
  14. data/lib/rrj/errors/error.rb +4 -3
  15. data/lib/rrj/errors/janus/janus.rb +20 -7
  16. data/lib/rrj/errors/janus/messages/admin.rb +33 -0
  17. data/lib/rrj/errors/janus/messages/message.rb +51 -0
  18. data/lib/rrj/errors/janus/messages/standard.rb +33 -0
  19. data/lib/rrj/errors/janus/processus/concurency.rb +23 -0
  20. data/lib/rrj/errors/janus/processus/event.rb +30 -0
  21. data/lib/rrj/errors/janus/processus/keepalive.rb +33 -0
  22. data/lib/rrj/errors/janus/responses/admin.rb +39 -0
  23. data/lib/rrj/errors/janus/responses/event.rb +46 -0
  24. data/lib/rrj/errors/janus/responses/response.rb +44 -0
  25. data/lib/rrj/errors/janus/responses/standard.rb +58 -0
  26. data/lib/rrj/errors/janus/transactions/admin.rb +37 -0
  27. data/lib/rrj/errors/janus/transactions/handle.rb +52 -0
  28. data/lib/rrj/errors/janus/transactions/session.rb +38 -0
  29. data/lib/rrj/errors/janus/transactions/transaction.rb +23 -0
  30. data/lib/rrj/errors/rabbit/connect.rb +58 -0
  31. data/lib/rrj/errors/rabbit/propertie.rb +37 -0
  32. data/lib/rrj/errors/rabbit/publish/admin.rb +30 -0
  33. data/lib/rrj/errors/rabbit/publish/base_publisher.rb +23 -0
  34. data/lib/rrj/errors/rabbit/publish/exclusive.rb +31 -0
  35. data/lib/rrj/errors/rabbit/publish/listener.rb +30 -0
  36. data/lib/rrj/errors/rabbit/publish/non_exclusive.rb +31 -0
  37. data/lib/rrj/errors/rabbit/publish/publisher.rb +30 -0
  38. data/lib/rrj/errors/rabbit/rabbit.rb +14 -23
  39. data/lib/rrj/errors/tools/gem/cluster.rb +44 -0
  40. data/lib/rrj/errors/tools/gem/config.rb +89 -0
  41. data/lib/rrj/errors/tools/gem/log.rb +86 -0
  42. data/lib/rrj/errors/tools/gem/option.rb +37 -0
  43. data/lib/rrj/errors/tools/gem/request.rb +23 -0
  44. data/lib/rrj/errors/tools/replaces/replace.rb +30 -0
  45. data/lib/rrj/errors/tools/replaces/type.rb +30 -0
  46. data/lib/rrj/errors/tools/tools.rb +21 -1
  47. data/lib/rrj/info.rb +1 -1
  48. data/lib/rrj/init.rb +22 -4
  49. data/lib/rrj/janus/messages/admin.rb +9 -4
  50. data/lib/rrj/janus/messages/message.rb +20 -9
  51. data/lib/rrj/janus/messages/standard.rb +8 -2
  52. data/lib/rrj/janus/processus/concurrency.rb +2 -0
  53. data/lib/rrj/janus/processus/event.rb +8 -0
  54. data/lib/rrj/janus/processus/keepalive.rb +15 -23
  55. data/lib/rrj/janus/responses/admin.rb +6 -0
  56. data/lib/rrj/janus/responses/event.rb +8 -0
  57. data/lib/rrj/janus/responses/response.rb +8 -11
  58. data/lib/rrj/janus/responses/standard.rb +12 -0
  59. data/lib/rrj/janus/transactions/admin.rb +6 -0
  60. data/lib/rrj/janus/transactions/handle.rb +25 -3
  61. data/lib/rrj/janus/transactions/session.rb +6 -0
  62. data/lib/rrj/janus/transactions/transaction.rb +3 -9
  63. data/lib/rrj/models/active_record.rb +14 -0
  64. data/lib/rrj/models/concerns/janus_instance_concern.rb +47 -0
  65. data/lib/rrj/models/mongoid.rb +19 -0
  66. data/lib/rrj/rabbit/connect.rb +12 -8
  67. data/lib/rrj/rabbit/propertie.rb +23 -6
  68. data/lib/rrj/rabbit/publish/admin.rb +4 -0
  69. data/lib/rrj/rabbit/publish/base_publisher.rb +2 -1
  70. data/lib/rrj/rabbit/publish/exclusive.rb +4 -0
  71. data/lib/rrj/rabbit/publish/listener.rb +6 -0
  72. data/lib/rrj/rabbit/publish/non_exclusive.rb +4 -0
  73. data/lib/rrj/rabbit/publish/publisher.rb +4 -4
  74. data/lib/rrj/railtie.rb +15 -0
  75. data/lib/rrj/task.rb +51 -0
  76. data/lib/rrj/tools/gem/cluster.rb +65 -0
  77. data/lib/rrj/tools/gem/config.rb +38 -6
  78. data/lib/rrj/tools/gem/log.rb +24 -4
  79. data/lib/rrj/tools/gem/option.rb +21 -17
  80. data/lib/rrj/tools/gem/requests.rb +11 -7
  81. data/lib/rrj/tools/replaces/replace.rb +4 -0
  82. data/lib/rrj/tools/replaces/type.rb +4 -0
  83. data/lib/rrj/tools/tools.rb +1 -0
  84. data/lib/ruby_rabbitmq_janus.rb +3 -0
  85. data/lib/tasks/delete_all_instance.rake +12 -0
  86. data/spec/request/admin/request_handle_info_spec.rb +4 -3
  87. data/spec/request/admin/request_handles_spec.rb +4 -3
  88. data/spec/request/peer/request_trickle_spec.rb +1 -1
  89. data/spec/rrj/rabbit/propertie_spec.rb +37 -2
  90. data/spec/rrj/tools/gem/rrj_cluster_spec.rb +26 -0
  91. data/spec/rrj/tools/gem/rrj_config_spec.rb +78 -0
  92. data/spec/rrj/tools/gem/rrj_log_spec.rb +55 -0
  93. data/spec/rrj/tools/{replace_admin_spec.rb → replace/replace_admin_spec.rb} +0 -0
  94. data/spec/rrj/tools/{replace_handle_spec.rb → replace/replace_handle_spec.rb} +0 -0
  95. data/spec/rrj/tools/{replace_session_spec.rb → replace/replace_session_spec.rb} +0 -0
  96. data/spec/rrj/tools/{replace_spec.rb → replace/replace_spec.rb} +0 -0
  97. data/spec/rrj/tools/{type_spec.rb → replace/type_spec.rb} +0 -0
  98. data/spec/spec_helper.rb +33 -2
  99. data/spec/support/examples_config.rb +10 -0
  100. data/spec/support/examples_message.rb +0 -2
  101. data/spec/support/examples_request.rb +4 -4
  102. data/spec/support/schemas/config/config.json +4 -2
  103. data/spec/support/schemas/config/rabbit_options.json +1 -1
  104. data/spec/support/schemas/config/rabbit_options2.json +13 -0
  105. data/spec/support/schemas/config/rabbit_options_admin.json +1 -1
  106. data/spec/support/schemas/config/rabbit_options_admin2.json +13 -0
  107. metadata +98 -17
  108. data/lib/rrj/errors/init.rb +0 -69
  109. data/lib/rrj/errors/janus/janus_message.rb +0 -53
  110. data/lib/rrj/errors/janus/janus_processus_keepalive.rb +0 -48
  111. data/lib/rrj/errors/janus/janus_response.rb +0 -89
  112. data/lib/rrj/errors/janus/janus_transaction.rb +0 -29
  113. data/lib/rrj/errors/tools/config.rb +0 -43
  114. data/spec/rrj/rrj_config_spec.rb +0 -67
  115. data/spec/rrj/rrj_log_spec.rb +0 -16
@@ -1,69 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # @author VAILLANT Jeremy <jeremy.vaillant@dazzl.tv>
4
-
5
- module RubyRabbitmqJanus
6
- # Define all error in gem
7
- module Errors
8
- # Define a super class for all errors in RRJ Class
9
- class RRJ < RRJError
10
- # Define a message error and level
11
- #
12
- # @param [String] message Text returning in raise
13
- # @param [Symbol] level Level to message in log
14
- def initalize(message, level)
15
- super "[RRJ] #{message}", level
16
- end
17
- end
18
-
19
- # Define an exception if gem dont initialize correctly
20
- class InstanciateGemFailed < RRJ
21
- # Initialize a error for instanciate class. It's a fatal error
22
- #
23
- # @param [String] message Text returning in raise
24
- def initialize(message)
25
- super "Gem is not instanciate correctly : #{message}", :fatal
26
- end
27
- end
28
-
29
- # Define an error if method message_post given an exception
30
- class TransactionSessionFailed < RRJ
31
- # Initialize a error for message posting. It's a fatal error
32
- #
33
- # @param [String] message Text returning in raise
34
- def initialize(message)
35
- super "Transaction SESSION failed : #{message}", :fatal
36
- end
37
- end
38
-
39
- # Define a error if method transaction given an exception
40
- class TransactionMessageFailed < RRJ
41
- # Initialize a error for transaction failed. It's a fatal error
42
- #
43
- # @param [String] message Text returning in raise
44
- def initialize(message)
45
- super "Message in a transaction HANDLE failed : #{message}", :fatal
46
- end
47
- end
48
-
49
- # Define a error if method start_handle given an exception
50
- class TransactionHandleFailed < RRJ
51
- # Initialize a error for transaction with a handle. It's a fatal error
52
- #
53
- # @param [String] message Text returning in raise
54
- def initialize(message)
55
- super "Transaction HANDLE failed : #{message}", :fatal
56
- end
57
- end
58
-
59
- # define a error for Admin Transaction
60
- class TransactionAdminFailed < RRJ
61
- # Initialize a error for transaction admin
62
- #
63
- # @param [String] message Text returning in raise
64
- def initialize(message)
65
- super "Transaction ADMIN failed : #{message}", :fatal
66
- end
67
- end
68
- end
69
- end
@@ -1,53 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module RubyRabbitmqJanus
4
- module Errors
5
- # @author VAILLANT Jeremy <jeremy.vaillant@dazzl.tv>
6
- #
7
- # Define an exception for janus message class
8
- class JanusMessage < Janus
9
- # Initialize a error for janus message module
10
- #
11
- # @param [String] message Text returning in raise
12
- def initialize(message)
13
- super "[Message] #{message}"
14
- end
15
- end
16
-
17
- # @author VAILLANT Jeremy <jeremy.vaillant@dazzl.tv>
18
- #
19
- # Define an exception for janus message to_json
20
- class JanusMessageJson < JanusMessage
21
- # Initialize a error for janus message in to_json
22
- #
23
- # @param [String] message Text returning in raise
24
- def initialize(message)
25
- super "Error transform to json : #{message}"
26
- end
27
- end
28
-
29
- # @author VAILLANT Jeremy <jeremy.vaillant@dazzl.tv>
30
- #
31
- # Define an exception for janus message to_nice_json
32
- class JanusMessagePrettyJson < JanusMessage
33
- # Initialize a error for janus message in to_nice_json
34
- #
35
- # @param [String] message Text returning in raise
36
- def initialize(message)
37
- super "Error transform to pretty json : #{message}"
38
- end
39
- end
40
-
41
- # @author VAILLANT Jeremy <jeremy.vaillant@dazzl.tv>
42
- #
43
- # Define an exception for janus message to_hash
44
- class JanusMessageHash < JanusMessage
45
- # Initialize a error for janus message in to_hash
46
- #
47
- # @param [String] message Text returning in raise
48
- def initialize(message)
49
- super "Error transform to hash : #{message}"
50
- end
51
- end
52
- end
53
- end
@@ -1,48 +0,0 @@
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
- # Define errors for keepalive class
9
- class Keepalive < Janus
10
- # Write a message with a tag keepalive in log
11
- def initialize(message)
12
- super "[Keepalive] #{message}"
13
- end
14
- end
15
-
16
- # Define error for session_return method
17
- class KeepaliveSessionReturn < Keepalive
18
- # Initialize a error message
19
- def initialize(message)
20
- super "Fixnum Session return failed : #{message}"
21
- end
22
- end
23
-
24
- # Define error for create_session method
25
- class KeepaliveCreateSession < Keepalive
26
- # Initialize a error message
27
- def initialize(message)
28
- super "Session create error : #{message}"
29
- end
30
- end
31
-
32
- # Define a error in loop_session method
33
- class KeepaliveLoopSession < Keepalive
34
- # Initialize a error message
35
- def initialize(message)
36
- super "Loop session failed (session will die) : #{message}"
37
- end
38
- end
39
-
40
- # Define a error in message keepalive created
41
- class KeepaliveMessage < Keepalive
42
- # Initialize a error message
43
- def initialize(message)
44
- super "Keepalive message failed : #{message}"
45
- end
46
- end
47
- end
48
- end
@@ -1,89 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # :reek:FeatureEnvy
4
-
5
- module RubyRabbitmqJanus
6
- module Errors
7
- # @author VAILLANT Jeremy <jeremy.vaillant@dazzl.tv>
8
- #
9
- # Define an error primary for response
10
- class JanusResponse < Janus
11
- # Initialize a error for janus response module
12
- #
13
- # @param [String] message Text returning in raise
14
- def initialize(message)
15
- super "[Response] #{message}"
16
- end
17
- end
18
-
19
- # @author VAILLANT Jeremy <jeremy.vaillant@dazzl.tv>
20
- #
21
- # Define an error for request return
22
- class JanusResponseRequest < JanusResponse
23
- # Initialize error
24
- def initialize(type_rqe, type_msg, message)
25
- "Error transform to #{type_rqe} : #{type_msg} -- message : #{message}"
26
- end
27
- end
28
-
29
- # @author VAILLANT Jeremy <jeremy.vaillant@dazzl.tv>
30
- #
31
- # Define an error for response initalize
32
- class JanusResponseInit < JanusResponse
33
- # Initialize a error for janus response module in initializer
34
- #
35
- # @param [String] message Text returning in raise
36
- def initialize(message)
37
- super "Error create object : #{message}"
38
- end
39
- end
40
-
41
- # @author VAILLANT Jeremy <jeremy.vaillant@dazzl.tv>
42
- #
43
- # Define an exception for json
44
- class JanusResponseJson < JanusResponseRequest
45
- # Initialize a error for janus response module in to_json
46
- #
47
- # @param [String] message Text returning in raise
48
- def initialize(message)
49
- super('JSON', message[0], message[1])
50
- end
51
- end
52
-
53
- # @author VAILLANT Jeremy <jeremy.vaillant@dazzl.tv>
54
- #
55
- # Define an exception for nice_json
56
- class JanusResponsePrettyJson < JanusResponse
57
- # Initialize a error for janus response module in to_nice_json
58
- #
59
- # @param [String] message Text returning in raise
60
- def initialize(message)
61
- super "Error transform to Pretty JSON : #{message}"
62
- end
63
- end
64
-
65
- # @author VAILLANT Jeremy <jeremy.vaillant@dazzl.tv>
66
- #
67
- # Define an exception for hash
68
- class JanusResponseHash < JanusResponseRequest
69
- # Initialize a error for janus response module in to_hash
70
- #
71
- # @param [String] message Text returning in raise
72
- def initialize(message)
73
- super('HASH', message[0], message[1])
74
- end
75
- end
76
-
77
- # @author VAILLANT Jeremy <jeremy.vaillant@dazzl.tv>
78
- #
79
- # Define an error for response data
80
- class JanusResponseDataId < JanusResponse
81
- # Initialize a error for janus response module in data_id
82
- #
83
- # @param [String] message Text returning in raise
84
- def initialize(message)
85
- super "Error Data : #{message}"
86
- end
87
- end
88
- end
89
- end
@@ -1,29 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- module RubyRabbitmqJanus
4
- module Errors
5
- # @author VAILLANT Jeremy <jeremy.vaillant@dazzl.tv>
6
- #
7
- # Define an exception for initalizer transaction
8
- class JanusTransaction < Janus
9
- # Initialize a error for janus transaction class
10
- #
11
- # @param [String] message Text returning in raise
12
- def initialize(message)
13
- super "[Transaction]#{message}"
14
- end
15
- end
16
-
17
- # @author VAILLANT Jeremy <jeremy.vaillant@dazzl.tv>
18
- #
19
- # Define an exception for running_handle
20
- class JanusTransactionHandle < JanusTransaction
21
- # Initialize a error for janus transaction handle class
22
- #
23
- # @param [String] message Text returning in raise
24
- def initialize(message)
25
- super "[Handle] #{message}"
26
- end
27
- end
28
- end
29
- end
@@ -1,43 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- # @author VAILLANT Jeremy <jeremy.vaillant@dazzl.tv>
4
-
5
- module RubyRabbitmqJanus
6
- module Errors
7
- # Define a super class for all error in class Config
8
- class Config < RRJError
9
- # Initalize a error for Config class
10
- def initialize(message, level)
11
- msg = "[Config] #{message} -- #{Tools::Log.instance.configuration}"
12
- super(msg, level)
13
- end
14
- end
15
-
16
- # Define an error if the configuration file is not here
17
- class FileNotFound < Config
18
- # Initialize a error for Config class if file don't exist.
19
- # It's a fatal error
20
- def initialize
21
- super 'Error for configuration file, does on exist.', :fatal
22
- end
23
- end
24
-
25
- # Define and error if rubrik level is not present
26
- class LevelNotDefine < Config
27
- # Initialize a error for config class if log level option is not present.
28
- # It's a warning error
29
- def initialize
30
- super \
31
- 'Error in configuration file : option level is not present.', :fatal
32
- end
33
- end
34
-
35
- # Define a error if janus/session/keepalive is not present
36
- class TTLNotFound < Config
37
- # Initialize a message error and level
38
- def initialize
39
- super 'Keepalive TTL option is not present in config file.', :fatal
40
- end
41
- end
42
- end
43
- end
@@ -1,67 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- describe RubyRabbitmqJanus::Tools::Config, type: :config, name: :config do
6
- before(:context) { @cfg = RubyRabbitmqJanus::Tools::Config.instance }
7
-
8
- it 'When file is correct' do
9
- expect(@cfg.options).to match_json_schema(:config)
10
- end
11
-
12
- it 'When janus/session/keepalive is correct type' do
13
- expect(@cfg.ttl).to be_a(Integer)
14
- end
15
-
16
- it 'When janus/session/keepalive default value is 55' do
17
- expect(@cfg.ttl).to eq 55
18
- end
19
-
20
- it 'When janus/plugins/0 is correct type' do
21
- expect(@cfg.plugin_at).to be_a(String)
22
- end
23
-
24
- it 'When janus/plugins/0 default value is janus.plugin.echotest' do
25
- expect(@cfg.plugin_at).to eq 'janus.plugin.echotest'
26
- end
27
-
28
- it 'When queues/standard/from is correct type' do
29
- expect(@cfg.queue_from).to be_a(String)
30
- end
31
-
32
- it 'When queues/standard/from default value is from-janus' do
33
- expect(@cfg.queue_from).to eq 'from-janus'
34
- end
35
-
36
- it 'When queues/standard/to is correct type' do
37
- expect(@cfg.queue_to).to be_a(String)
38
- end
39
-
40
- it 'When queues/standard/to default value is to-janus' do
41
- expect(@cfg.queue_to).to eq 'to-janus'
42
- end
43
-
44
- it 'When queues/admin/from is correct type' do
45
- expect(@cfg.queue_admin_from).to be_a(String)
46
- end
47
-
48
- it 'When queues/admin/from default value is from-janus-admin' do
49
- expect(@cfg.queue_admin_from).to eq 'from-janus-admin'
50
- end
51
-
52
- it 'When queues/admin/to is correct type' do
53
- expect(@cfg.queue_admin_to).to be_a(String)
54
- end
55
-
56
- it 'When queues/admin/to default value is to-janus-admin' do
57
- expect(@cfg.queue_admin_to).to eq 'to-janus-admin'
58
- end
59
-
60
- it 'When gem/log/level is correct type' do
61
- expect(@cfg.log_level).to be_a(Symbol)
62
- end
63
-
64
- it 'When gem/log/level default value is INFO' do
65
- expect(@cfg.log_level).to eq :INFO
66
- end
67
- end
@@ -1,16 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'spec_helper'
4
-
5
- describe 'RubyRabbitmqJanus::Log', type: :config, name: :log do
6
- it 'Log instance is correctly loading' do
7
- expect(RubyRabbitmqJanus::Tools::Log.instance).not_to be nil
8
- end
9
-
10
- it 'Default level log is INFO' do
11
- # 0 = debug
12
- # ...
13
- # 5 = unknown
14
- expect(RubyRabbitmqJanus::Tools::Log.instance.level).to eq 1
15
- end
16
- end