ruby_rabbitmq_janus 3.0.0.pre.354 → 3.0.0.pre.384
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Rakefile +1 -2
- data/lib/generators/ruby_rabbitmq_janus/migration_generator.rb +2 -0
- data/lib/rrj/errors/error.rb +1 -1
- data/lib/rrj/janus/responses/admin.rb +13 -9
- data/lib/rrj/janus/responses/error.rb +0 -2
- data/lib/rrj/janus/responses/rspec.rb +2 -0
- data/lib/rrj/janus/responses/standard.rb +1 -0
- data/lib/rrj/janus/transactions/handle.rb +2 -0
- data/lib/rrj/janus/transactions/rspec.rb +2 -0
- data/lib/rrj/janus/transactions/session.rb +1 -0
- data/lib/rrj/models/active_record.rb +3 -0
- data/lib/rrj/models/concerns/instances.rb +11 -6
- data/lib/rrj/process/concurrency.rb +15 -5
- data/lib/rrj/process/event.rb +7 -5
- data/lib/rrj/process/event_admin.rb +7 -5
- data/lib/rrj/process/thread_runner_concern.rb +30 -29
- data/lib/rrj/rabbit/base_event.rb +2 -2
- data/lib/rrj/rabbit/connect.rb +21 -4
- data/lib/rrj/rabbit/listener/base.rb +17 -1
- data/lib/rrj/rabbit/listener/from.rb +2 -15
- data/lib/rrj/rabbit/listener/from_admin.rb +2 -15
- data/lib/rrj/rabbit/publisher/non_exclusive.rb +3 -0
- data/lib/rrj/rails.rb +9 -5
- data/lib/rrj/rspec.rb +5 -0
- data/lib/rrj/task.rb +2 -0
- data/lib/rrj/tools/gem/config/gem.rb +1 -1
- data/lib/rrj/tools/gem/logger.rb +1 -2
- data/lib/rrj/tools/gem/requests.rb +2 -2
- data/spec/config/database.rb +1 -0
- data/spec/factories/janus_instance.rb +2 -0
- data/spec/ruby_rabbitmq_janus/janus/responses/errors_spec.rb +175 -0
- data/spec/ruby_rabbitmq_janus/janus/responses/response_spec.rb +1 -1
- data/spec/ruby_rabbitmq_janus/models/{janus_instance_definition_spec.rb → janus_instance_field_spec.rb} +0 -0
- data/spec/ruby_rabbitmq_janus/models/janus_instance_instance_spec.rb +47 -0
- data/spec/ruby_rabbitmq_janus/models/{janus_instance_spec.rb → janus_instance_validation_spec.rb} +10 -2
- data/spec/ruby_rabbitmq_janus/process/concurrencies/concurrency_spec.rb +1 -5
- data/spec/ruby_rabbitmq_janus/process/concurrencies/event_admin_spec.rb +3 -2
- data/spec/ruby_rabbitmq_janus/process/concurrencies/event_spec.rb +3 -2
- data/spec/ruby_rabbitmq_janus/rabbit/listener/from_spec.rb +1 -0
- data/spec/ruby_rabbitmq_janus/rabbit/publisher/admin_spec.rb +1 -0
- data/spec/ruby_rabbitmq_janus/rabbit/publisher/exclusive_spec.rb +4 -3
- data/spec/ruby_rabbitmq_janus/rabbit/publisher/non_exclusive_spec.rb +4 -4
- data/spec/ruby_rabbitmq_janus/tools/logger_spec.rb +34 -0
- data/spec/ruby_rabbitmq_janus/tools/replaces/admin_spec.rb +2 -2
- data/spec/ruby_rabbitmq_janus/tools/replaces/handle_spec.rb +1 -1
- data/spec/ruby_rabbitmq_janus/tools/type_spec.rb +1 -1
- data/spec/spec_helper.rb +27 -3
- data/spec/support/examples_model.rb +45 -0
- data/spec/support/examples_thread.rb +21 -15
- data/tmp/coverage/assets/0.10.2/application.css +799 -0
- data/tmp/coverage/assets/0.10.2/application.js +1707 -0
- data/tmp/coverage/assets/0.10.2/colorbox/border.png +0 -0
- data/tmp/coverage/assets/0.10.2/colorbox/controls.png +0 -0
- data/tmp/coverage/assets/0.10.2/colorbox/loading.gif +0 -0
- data/tmp/coverage/assets/0.10.2/colorbox/loading_background.png +0 -0
- data/tmp/coverage/assets/0.10.2/favicon_green.png +0 -0
- data/tmp/coverage/assets/0.10.2/favicon_red.png +0 -0
- data/tmp/coverage/assets/0.10.2/favicon_yellow.png +0 -0
- data/tmp/coverage/assets/0.10.2/loading.gif +0 -0
- data/tmp/coverage/assets/0.10.2/magnify.png +0 -0
- data/tmp/coverage/assets/0.10.2/smoothness/images/ui-bg_flat_0_aaaaaa_40x100.png +0 -0
- data/tmp/coverage/assets/0.10.2/smoothness/images/ui-bg_flat_75_ffffff_40x100.png +0 -0
- data/tmp/coverage/assets/0.10.2/smoothness/images/ui-bg_glass_55_fbf9ee_1x400.png +0 -0
- data/tmp/coverage/assets/0.10.2/smoothness/images/ui-bg_glass_65_ffffff_1x400.png +0 -0
- data/tmp/coverage/assets/0.10.2/smoothness/images/ui-bg_glass_75_dadada_1x400.png +0 -0
- data/tmp/coverage/assets/0.10.2/smoothness/images/ui-bg_glass_75_e6e6e6_1x400.png +0 -0
- data/tmp/coverage/assets/0.10.2/smoothness/images/ui-bg_glass_95_fef1ec_1x400.png +0 -0
- data/tmp/coverage/assets/0.10.2/smoothness/images/ui-bg_highlight-soft_75_cccccc_1x100.png +0 -0
- data/tmp/coverage/assets/0.10.2/smoothness/images/ui-icons_222222_256x240.png +0 -0
- data/tmp/coverage/assets/0.10.2/smoothness/images/ui-icons_2e83ff_256x240.png +0 -0
- data/tmp/coverage/assets/0.10.2/smoothness/images/ui-icons_454545_256x240.png +0 -0
- data/tmp/coverage/assets/0.10.2/smoothness/images/ui-icons_888888_256x240.png +0 -0
- data/tmp/coverage/assets/0.10.2/smoothness/images/ui-icons_cd0a0a_256x240.png +0 -0
- data/tmp/coverage/index.html +21339 -0
- metadata +73 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e3f09817fed0214a2ce8a776ea6cb6c7c3ea893c24f56af5c2cec9855883d5f5
|
4
|
+
data.tar.gz: 108b9f75fbb86c4698ada11ff575568e5e80d7ee42c46a05da9713b375414868
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: fbfce5a5a397afbfcb3e25a4f435f7149382584146099ab6f0e8eb73e4f64095e38401a74b38c581765e3c6592f5b7807f88007bdd2b91ca172e7241528b0fea
|
7
|
+
data.tar.gz: 32d45c9f76089d812d71ca10b2c085f160cabe3f85ffbe54d56075cc9db81eaaf83a111d05c8536d3d63cc40084fffc5bb52241ab853b4988a9636eb6d042a9d
|
data/Rakefile
CHANGED
@@ -4,8 +4,7 @@ require 'bundler/gem_tasks'
|
|
4
4
|
require 'rspec/core/rake_task'
|
5
5
|
|
6
6
|
# Exclude all spec with type :thread
|
7
|
-
RSpec::Core::RakeTask.new(:spec)
|
8
|
-
end
|
7
|
+
RSpec::Core::RakeTask.new(:spec)
|
9
8
|
|
10
9
|
# Exclude all spec with type :thread
|
11
10
|
RSpec::Core::RakeTask.new(:classic) do |t|
|
@@ -16,11 +16,13 @@ module RubyRabbitmqJanus
|
|
16
16
|
|
17
17
|
source_root File.expand_path('templates', __dir__)
|
18
18
|
|
19
|
+
# Prepare files for migration.
|
19
20
|
def install
|
20
21
|
migration_template 'migration.rb',
|
21
22
|
'db/migrate/create_ruby_rabbitmq_janus_tables.rb'
|
22
23
|
end
|
23
24
|
|
25
|
+
# Determines the version number of the next migration.
|
24
26
|
def self.next_migration_number(dirname)
|
25
27
|
ActiveRecord::Generators::Base.next_migration_number(dirname)
|
26
28
|
end
|
data/lib/rrj/errors/error.rb
CHANGED
@@ -20,7 +20,7 @@ module RubyRabbitmqJanus
|
|
20
20
|
|
21
21
|
def write_error(message, level = :unknown)
|
22
22
|
if defined?(::Log)
|
23
|
-
::Log.send(level.
|
23
|
+
::Log.send(level.instance_of?(Symbol) ? level : int_to_level(level),
|
24
24
|
message)
|
25
25
|
else
|
26
26
|
p "#{level}, #{message}"
|
@@ -7,55 +7,59 @@ module RubyRabbitmqJanus
|
|
7
7
|
#
|
8
8
|
# @see Example request response https://janus.conf.meetecho.com/docs/admin.html
|
9
9
|
class Admin < Standard
|
10
|
-
# List of sessions running in Janus Instance.
|
11
|
-
#
|
12
|
-
# @return [Array] List of sessions
|
10
|
+
# @return [Array] List of sessions running in Janus Instance.
|
13
11
|
def sessions
|
14
12
|
read_data(__method__.to_s)
|
15
13
|
end
|
16
14
|
|
17
|
-
# List of handles running
|
18
|
-
#
|
19
|
-
# @return [Array] List of handles
|
15
|
+
# @return [Array] List of handles running
|
16
|
+
# in one session in Janus Instance.
|
20
17
|
def handles
|
21
18
|
read_data(__method__.to_s)
|
22
19
|
end
|
23
20
|
|
24
|
-
#
|
25
|
-
#
|
26
|
-
# @return [Hash] Information to session/handle
|
21
|
+
# @return [Hash] Information to session/handle in Janus Instance.
|
27
22
|
def info
|
28
23
|
read_data(__method__.to_s)
|
29
24
|
end
|
30
25
|
|
26
|
+
# @return [Boolean] Information status to debug mode for libnice.
|
31
27
|
def libnice_debug
|
32
28
|
read_data(__method__.to_s)
|
33
29
|
end
|
34
30
|
|
31
|
+
# @return [Boolean] Information status to debug mode
|
32
|
+
# in Janus Intance on the fly.
|
35
33
|
def locking_debug
|
36
34
|
read_data(__method__.to_s)
|
37
35
|
end
|
38
36
|
|
37
|
+
# @return [Boolean] Information about color in log messages.
|
39
38
|
def log_colors
|
40
39
|
read_data(__method__.to_s)
|
41
40
|
end
|
42
41
|
|
42
|
+
# @return [Integer] Level to debug mode to Janus Instance.
|
43
43
|
def level
|
44
44
|
read_data(__method__.to_s)
|
45
45
|
end
|
46
46
|
|
47
|
+
# @return [Boolean] Status to timestampping for log messages.
|
47
48
|
def log_timestamps
|
48
49
|
read_data(__method__.to_s)
|
49
50
|
end
|
50
51
|
|
52
|
+
# @return [Integer] Level to max nack queue configured.
|
51
53
|
def max_nack_queue
|
52
54
|
read_data(__method__.to_s)
|
53
55
|
end
|
54
56
|
|
57
|
+
# @return [Integer] No-media timer property.
|
55
58
|
def no_media_timer
|
56
59
|
read_data(__method__.to_s)
|
57
60
|
end
|
58
61
|
|
62
|
+
# @return [Integer] Timeout for session.
|
59
63
|
def timeout
|
60
64
|
read_data(__method__.to_s)
|
61
65
|
end
|
@@ -143,11 +143,9 @@ module RubyRabbitmqJanus
|
|
143
143
|
|
144
144
|
def respond_to_missing?(name, include_private); end
|
145
145
|
|
146
|
-
# rubocop:disable Style/MethodMissingSuper
|
147
146
|
def method_missing(_method, request)
|
148
147
|
default_error(request)
|
149
148
|
end
|
150
|
-
# rubocop:enable Style/MethodMissingSuper
|
151
149
|
|
152
150
|
def default_error(request)
|
153
151
|
raise RubyRabbitmqJanus::Errors::Janus::Responses::Nok, request
|
@@ -7,6 +7,8 @@ module RubyRabbitmqJanus
|
|
7
7
|
module Responses
|
8
8
|
# Response for RSpec initializer
|
9
9
|
class RSpec
|
10
|
+
# Constructor to RSpec response.
|
11
|
+
# Create a fake response for testing library.
|
10
12
|
def initialize(type)
|
11
13
|
path = RubyRabbitmqJanus::Tools::Config.instance.rspec_response
|
12
14
|
@json = File.join(Dir.pwd,
|
@@ -70,11 +70,13 @@ module RubyRabbitmqJanus
|
|
70
70
|
@handle = send_a_message_exclusive { msg }
|
71
71
|
end
|
72
72
|
|
73
|
+
# rubocop:disable Style/ExplicitBlockArgument
|
73
74
|
def send_a_message_exclusive
|
74
75
|
Janus::Responses::Standard.new(read_response_exclusive do
|
75
76
|
yield
|
76
77
|
end).sender
|
77
78
|
end
|
79
|
+
# rubocop:enable Style/ExplicitBlockArgument
|
78
80
|
|
79
81
|
def read_response_exclusive
|
80
82
|
chan = rabbit.channel
|
@@ -31,9 +31,12 @@ module RubyRabbitmqJanus
|
|
31
31
|
# @param attributes [Array] List to attribute to delete in document
|
32
32
|
#
|
33
33
|
# @return [Hash] Current model
|
34
|
+
#
|
35
|
+
# rubocop:disable Style/HashTransformValues
|
34
36
|
def unset(attributes)
|
35
37
|
Hash[attributes.map { |key, _value| [key, nil] }]
|
36
38
|
end
|
39
|
+
# rubocop:enable Style/HashTransformValues
|
37
40
|
end
|
38
41
|
end
|
39
42
|
end
|
@@ -12,32 +12,37 @@ module RubyRabbitmqJanus
|
|
12
12
|
module ClassMethods
|
13
13
|
# Disable an instance
|
14
14
|
def disable(session_id)
|
15
|
-
|
15
|
+
find_by_session(session_id).set(enable: false)
|
16
|
+
end
|
17
|
+
|
18
|
+
# Enable an instance
|
19
|
+
def enable(session_id)
|
20
|
+
find_by_session(session_id).set(enable: true)
|
16
21
|
end
|
17
22
|
|
18
23
|
# Clean all instance disabled
|
19
24
|
def destroys
|
20
|
-
|
25
|
+
where(enable: false).delete_all
|
21
26
|
end
|
22
27
|
|
23
28
|
# Search a record by instance number
|
24
29
|
def find_by_instance(instance_search)
|
25
|
-
|
30
|
+
find_by(instance: instance_search)
|
26
31
|
end
|
27
32
|
|
28
33
|
# Search a record by session number
|
29
34
|
def find_by_session(session_search)
|
30
|
-
|
35
|
+
find_by(session_id: session_search)
|
31
36
|
end
|
32
37
|
|
33
38
|
# Get all instance active
|
34
39
|
def enabled
|
35
|
-
|
40
|
+
where(enable: true)
|
36
41
|
end
|
37
42
|
|
38
43
|
# Get all instance not active
|
39
44
|
def disabled
|
40
|
-
|
45
|
+
where(enable: false)
|
41
46
|
end
|
42
47
|
end
|
43
48
|
end
|
@@ -27,19 +27,29 @@ module RubyRabbitmqJanus
|
|
27
27
|
def initialize_thread
|
28
28
|
@rabbit.transaction_long { transaction_running }
|
29
29
|
rescue Interrupt
|
30
|
-
::Log.warn
|
31
|
-
|
32
|
-
|
30
|
+
::Log.warn "This process has been interupted #{class_name}"
|
31
|
+
close
|
32
|
+
else
|
33
|
+
close
|
33
34
|
end
|
34
35
|
|
35
36
|
def info_thread
|
36
|
-
"Create an thread -- #{
|
37
|
+
"Create an thread -- #{class_name}"
|
38
|
+
end
|
39
|
+
|
40
|
+
def class_name
|
41
|
+
self.class.name
|
42
|
+
end
|
43
|
+
|
44
|
+
def close
|
45
|
+
::Log.warn \
|
46
|
+
"Close a connection with RabbitMQ instance for #{class_name}"
|
47
|
+
@rabbit.close
|
37
48
|
end
|
38
49
|
end
|
39
50
|
end
|
40
51
|
end
|
41
52
|
end
|
42
53
|
|
43
|
-
require 'rrj/process/thread_runner_concern'
|
44
54
|
require 'rrj/process/event'
|
45
55
|
require 'rrj/process/event_admin'
|
data/lib/rrj/process/event.rb
CHANGED
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'rrj/process/thread_runner_concern'
|
4
|
+
|
3
5
|
module RubyRabbitmqJanus
|
4
6
|
module Process
|
5
7
|
module Concurrencies
|
@@ -16,17 +18,17 @@ module RubyRabbitmqJanus
|
|
16
18
|
|
17
19
|
private
|
18
20
|
|
19
|
-
def raise_nil_block
|
20
|
-
raise RubyRabbitmqJanus::Errors::Process::Event::Run
|
21
|
-
end
|
22
|
-
|
23
21
|
def name_publisher
|
24
|
-
:
|
22
|
+
:pub_classic
|
25
23
|
end
|
26
24
|
|
27
25
|
def publisher
|
28
26
|
Rabbit::Listener::From.new(rabbit)
|
29
27
|
end
|
28
|
+
|
29
|
+
def raise_nil_block
|
30
|
+
raise RubyRabbitmqJanus::Errors::Process::Event::Run
|
31
|
+
end
|
30
32
|
end
|
31
33
|
end
|
32
34
|
end
|
@@ -1,5 +1,7 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
+
require 'rrj/process/thread_runner_concern'
|
4
|
+
|
3
5
|
module RubyRabbitmqJanus
|
4
6
|
module Process
|
5
7
|
module Concurrencies
|
@@ -16,17 +18,17 @@ module RubyRabbitmqJanus
|
|
16
18
|
|
17
19
|
private
|
18
20
|
|
19
|
-
def raise_nil_block
|
20
|
-
raise RubyRabbitmqJanus::Errors::Process::EventAdmin::Run
|
21
|
-
end
|
22
|
-
|
23
21
|
def name_publisher
|
24
|
-
:
|
22
|
+
:pub_admin
|
25
23
|
end
|
26
24
|
|
27
25
|
def publisher
|
28
26
|
Rabbit::Listener::FromAdmin.new(rabbit)
|
29
27
|
end
|
28
|
+
|
29
|
+
def raise_nil_block
|
30
|
+
raise RubyRabbitmqJanus::Errors::Process::EventAdmin::Run
|
31
|
+
end
|
30
32
|
end
|
31
33
|
end
|
32
34
|
end
|
@@ -13,41 +13,42 @@ module RubyRabbitmqJanus
|
|
13
13
|
module ThreadRunnerConcern
|
14
14
|
extend ActiveSupport::Concern
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
16
|
+
included do
|
17
|
+
# Initialize an process (event/event_admin) and configure
|
18
|
+
# the life cycle to thread.
|
19
|
+
def initialize
|
20
|
+
super
|
21
|
+
@thread = Thread.new { initialize_thread }
|
22
|
+
end
|
23
23
|
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
24
|
+
# Create a thread for execute a block code in a thread.
|
25
|
+
# This code is outside to `RRJ` gem so is very important
|
26
|
+
# to be sure this code execution is not fail.
|
27
|
+
#
|
28
|
+
# @param [Proc] block Block code for execute action when queue
|
29
|
+
# standard 'from-janus' receive a message.This block is sending to
|
30
|
+
# publisher created for this thread.
|
31
|
+
#
|
32
|
+
# @return [Thread] It's a thread who listen queue and execute action
|
33
|
+
def run(&block)
|
34
|
+
raise_nil_block unless block
|
35
35
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
36
|
+
@thread.join
|
37
|
+
Thread.new do
|
38
|
+
loop do
|
39
|
+
@thread.thread_variable_get(name_publisher)
|
40
|
+
.listen_events(&block)
|
41
|
+
rescue => exception
|
42
|
+
::Log.warn exception
|
43
|
+
end
|
43
44
|
end
|
44
45
|
end
|
45
|
-
end
|
46
46
|
|
47
|
-
|
47
|
+
private
|
48
48
|
|
49
|
-
|
50
|
-
|
49
|
+
def transaction_running
|
50
|
+
@thread.thread_variable_set(name_publisher, publisher)
|
51
|
+
end
|
51
52
|
end
|
52
53
|
end
|
53
54
|
end
|
@@ -10,9 +10,9 @@ module RubyRabbitmqJanus
|
|
10
10
|
# # Parent class for all publisher
|
11
11
|
# This element send and read a message in rabbitmq Queue
|
12
12
|
#
|
13
|
-
# @!attribute [r]
|
13
|
+
# @!attribute [r] responses
|
14
14
|
# @return [RubyRabbitmqJanus::Janus::Responses::Response]
|
15
|
-
# Given
|
15
|
+
# Given an array of Janus response
|
16
16
|
#
|
17
17
|
# @abstract Publish message in RabbitMQ
|
18
18
|
class BaseEvent
|
data/lib/rrj/rabbit/connect.rb
CHANGED
@@ -14,10 +14,17 @@ module RubyRabbitmqJanus
|
|
14
14
|
end
|
15
15
|
|
16
16
|
# Create an transaction with rabbitmq and close after response is received
|
17
|
-
def transaction_short
|
18
|
-
raise Errors::Rabbit::Connect::MissingAction unless
|
17
|
+
def transaction_short(&block)
|
18
|
+
raise Errors::Rabbit::Connect::MissingAction unless block
|
19
|
+
|
20
|
+
response = nil
|
19
21
|
|
20
|
-
|
22
|
+
Timeout.timeout(5) do
|
23
|
+
response = transaction_long(&block)
|
24
|
+
end
|
25
|
+
rescue Timeout::Error
|
26
|
+
::Log.error 'The "Short transaction" have raised Timeout exception.'
|
27
|
+
ensure
|
21
28
|
close
|
22
29
|
response
|
23
30
|
end
|
@@ -30,6 +37,8 @@ module RubyRabbitmqJanus
|
|
30
37
|
start
|
31
38
|
yield
|
32
39
|
end
|
40
|
+
rescue Timeout::Error
|
41
|
+
::Log.error 'The "Long transaction" have raised Timeout exception.'
|
33
42
|
end
|
34
43
|
|
35
44
|
# Opening a connection with RabbitMQ
|
@@ -50,7 +59,15 @@ module RubyRabbitmqJanus
|
|
50
59
|
private
|
51
60
|
|
52
61
|
def bunny_conf
|
53
|
-
Tools::Config.instance.server_settings.merge(
|
62
|
+
Tools::Config.instance.server_settings.merge(bunny_conf_static)
|
63
|
+
end
|
64
|
+
|
65
|
+
def bunny_conf_static
|
66
|
+
{
|
67
|
+
connection_timeout: 5,
|
68
|
+
connection_name: "[#{rand(999)}] backend",
|
69
|
+
recover_from_connection_close: false
|
70
|
+
}
|
54
71
|
end
|
55
72
|
end
|
56
73
|
end
|