ruby_rabbitmq_janus 3.0.0.pre.354 → 3.0.0.pre.358
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rrj/models/concerns/instances.rb +11 -6
- data/lib/rrj/process/concurrency.rb +0 -1
- 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/rails.rb +9 -5
- 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/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/tools/logger_spec.rb +34 -0
- data/spec/spec_helper.rb +23 -1
- data/spec/support/examples_model.rb +45 -0
- data/spec/support/examples_thread.rb +15 -9
- 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 +21117 -0
- metadata +47 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d71f0e648c88b66a515f531f9363854ac8bfe3219412ab6c25dbbad0e35c49ae
|
4
|
+
data.tar.gz: f6188b1fff85bd230cc0d44356c879388eb32d809e70a26248c00261e5ff23de
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: ea2469541044db09a0b6fdfb34371f81cd441b7e2a8e566876628a88a2742b8be18e5af996eef47df3adf9d2a8076a5c562a0e4116a3b0a9bae2dc5b185133b7
|
7
|
+
data.tar.gz: b611d921872a181c05d4da95f7dddc75f032842fa48ba3435bba379465267b8e3674b99d84149e577d9252665156115bf9f0ba6894e0c091920542248aef4279
|
@@ -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
|
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_given?
|
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
|
data/lib/rrj/rails.rb
CHANGED
@@ -25,11 +25,15 @@ module RubyRabbitmqJanus
|
|
25
25
|
actions = RubyRabbitmqJanus::ActionEvents.new.actions
|
26
26
|
admin_actions = RubyRabbitmqJanus::ActionAdminEvents.new.actions
|
27
27
|
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
28
|
+
listeners = []
|
29
|
+
(1..number).each do
|
30
|
+
listeners.push process::Event.new.run(&actions)
|
31
|
+
listeners.push process::EventAdmin.new.run(&admin_actions)
|
32
|
+
end
|
33
|
+
|
34
|
+
Parallel.each(listeners, in_processes: number) do |listener|
|
35
|
+
item = "[Item##{listener}]"
|
36
|
+
Log.warn "#{item}, Worker : #{Parallel.worker_number + 1} / #{number}"
|
33
37
|
end
|
34
38
|
end
|
35
39
|
end
|
data/spec/config/database.rb
CHANGED
@@ -0,0 +1,175 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe RubyRabbitmqJanus::Janus::Responses::Errors, type: :responses,
|
6
|
+
name: :errors do
|
7
|
+
let(:message) do
|
8
|
+
{
|
9
|
+
'janus' => 'error',
|
10
|
+
'error' => {
|
11
|
+
'code' => number,
|
12
|
+
'reason' => reason
|
13
|
+
}
|
14
|
+
}
|
15
|
+
end
|
16
|
+
let(:response) { RubyRabbitmqJanus::Janus::Responses::Response.new(message) }
|
17
|
+
let(:error) { described_class.new }
|
18
|
+
let(:reason) { [*('a'..'z'), *('0'..'9')].sample(12).join }
|
19
|
+
|
20
|
+
context 'when 403' do
|
21
|
+
let(:number) { 403 }
|
22
|
+
|
23
|
+
it { expect { error.send(:"_#{number}", response) }.to raise_error(RubyRabbitmqJanus::Errors::Janus::Responses::Unauthorized) }
|
24
|
+
end
|
25
|
+
|
26
|
+
context 'when 405' do
|
27
|
+
let(:number) { 405 }
|
28
|
+
|
29
|
+
it { expect { error.send(:"_#{number}", response) }.to raise_error(RubyRabbitmqJanus::Errors::Janus::Responses::UnauthorizedPlugin) }
|
30
|
+
end
|
31
|
+
|
32
|
+
context 'when 450' do
|
33
|
+
let(:number) { 450 }
|
34
|
+
|
35
|
+
it { expect { error.send(:"_#{number}", response) }.to raise_error(RubyRabbitmqJanus::Errors::Janus::Responses::TransportSpecific) }
|
36
|
+
end
|
37
|
+
|
38
|
+
context 'when 452' do
|
39
|
+
let(:number) { 452 }
|
40
|
+
|
41
|
+
it { expect { error.send(:"_#{number}", response) }.to raise_error(RubyRabbitmqJanus::Errors::Janus::Responses::MissingRequest) }
|
42
|
+
end
|
43
|
+
|
44
|
+
context 'when 453' do
|
45
|
+
let(:number) { 453 }
|
46
|
+
|
47
|
+
it { expect { error.send(:"_#{number}", response) }.to raise_error(RubyRabbitmqJanus::Errors::Janus::Responses::UnknownRequest) }
|
48
|
+
end
|
49
|
+
|
50
|
+
context 'when 454' do
|
51
|
+
let(:number) { 454 }
|
52
|
+
|
53
|
+
it { expect { error.send(:"_#{number}", response) }.to raise_error(RubyRabbitmqJanus::Errors::Janus::Responses::InvalidJSON) }
|
54
|
+
end
|
55
|
+
|
56
|
+
context 'when 455' do
|
57
|
+
let(:number) { 455 }
|
58
|
+
|
59
|
+
it { expect { error.send(:"_#{number}", response) }.to raise_error(RubyRabbitmqJanus::Errors::Janus::Responses::InvalidJSONObject) }
|
60
|
+
end
|
61
|
+
|
62
|
+
context 'when 456' do
|
63
|
+
let(:number) { 456 }
|
64
|
+
|
65
|
+
it { expect { error.send(:"_#{number}", response) }.to raise_error(RubyRabbitmqJanus::Errors::Janus::Responses::MissingMandatoryElement) }
|
66
|
+
end
|
67
|
+
|
68
|
+
context 'when 457' do
|
69
|
+
let(:number) { 457 }
|
70
|
+
|
71
|
+
it { expect { error.send(:"_#{number}", response) }.to raise_error(RubyRabbitmqJanus::Errors::Janus::Responses::InvalidRequestPath) }
|
72
|
+
end
|
73
|
+
|
74
|
+
context 'when 458' do
|
75
|
+
let(:number) { 458 }
|
76
|
+
|
77
|
+
it { expect { error.send(:"_#{number}", response) }.to raise_error(RubyRabbitmqJanus::Errors::Janus::Responses::SessionNotFound) }
|
78
|
+
end
|
79
|
+
|
80
|
+
context 'when 459' do
|
81
|
+
let(:number) { 459 }
|
82
|
+
|
83
|
+
it { expect { error.send(:"_#{number}", response) }.to raise_error(RubyRabbitmqJanus::Errors::Janus::Responses::HandleNotFound) }
|
84
|
+
end
|
85
|
+
|
86
|
+
context 'when 460' do
|
87
|
+
let(:number) { 460 }
|
88
|
+
|
89
|
+
it { expect { error.send(:"_#{number}", response) }.to raise_error(RubyRabbitmqJanus::Errors::Janus::Responses::PluginNotFound) }
|
90
|
+
end
|
91
|
+
|
92
|
+
context 'when 461' do
|
93
|
+
let(:number) { 461 }
|
94
|
+
|
95
|
+
it { expect { error.send(:"_#{number}", response) }.to raise_error(RubyRabbitmqJanus::Errors::Janus::Responses::PluginAttach) }
|
96
|
+
end
|
97
|
+
|
98
|
+
context 'when 462' do
|
99
|
+
let(:number) { 462 }
|
100
|
+
|
101
|
+
it { expect { error.send(:"_#{number}", response) }.to raise_error(RubyRabbitmqJanus::Errors::Janus::Responses::PluginMessage) }
|
102
|
+
end
|
103
|
+
|
104
|
+
context 'when 463' do
|
105
|
+
let(:number) { 463 }
|
106
|
+
|
107
|
+
it { expect { error.send(:"_#{number}", response) }.to raise_error(RubyRabbitmqJanus::Errors::Janus::Responses::PluginDetach) }
|
108
|
+
end
|
109
|
+
|
110
|
+
context 'when 464' do
|
111
|
+
let(:number) { 464 }
|
112
|
+
|
113
|
+
it { expect { error.send(:"_#{number}", response) }.to raise_error(RubyRabbitmqJanus::Errors::Janus::Responses::JSEPUnknownType) }
|
114
|
+
end
|
115
|
+
|
116
|
+
context 'when 465' do
|
117
|
+
let(:number) { 465 }
|
118
|
+
|
119
|
+
it { expect { error.send(:"_#{number}", response) }.to raise_error(RubyRabbitmqJanus::Errors::Janus::Responses::JSEPInvalidSDP) }
|
120
|
+
end
|
121
|
+
|
122
|
+
context 'when 466' do
|
123
|
+
let(:number) { 466 }
|
124
|
+
|
125
|
+
it { expect { error.send(:"_#{number}", response) }.to raise_error(RubyRabbitmqJanus::Errors::Janus::Responses::TrickleInvalidStream) }
|
126
|
+
end
|
127
|
+
|
128
|
+
context 'when 467' do
|
129
|
+
let(:number) { 467 }
|
130
|
+
|
131
|
+
it { expect { error.send(:"_#{number}", response) }.to raise_error(RubyRabbitmqJanus::Errors::Janus::Responses::InvalidElementType) }
|
132
|
+
end
|
133
|
+
|
134
|
+
context 'when 468' do
|
135
|
+
let(:number) { 468 }
|
136
|
+
|
137
|
+
it { expect { error.send(:"_#{number}", response) }.to raise_error(RubyRabbitmqJanus::Errors::Janus::Responses::SessionConflit) }
|
138
|
+
end
|
139
|
+
|
140
|
+
context 'when 469' do
|
141
|
+
let(:number) { 469 }
|
142
|
+
|
143
|
+
it { expect { error.send(:"_#{number}", response) }.to raise_error(RubyRabbitmqJanus::Errors::Janus::Responses::UnexpectedAnswer) }
|
144
|
+
end
|
145
|
+
|
146
|
+
context 'when 470' do
|
147
|
+
let(:number) { 470 }
|
148
|
+
|
149
|
+
it { expect { error.send(:"_#{number}", response) }.to raise_error(RubyRabbitmqJanus::Errors::Janus::Responses::TokenNotFound) }
|
150
|
+
end
|
151
|
+
|
152
|
+
context 'when 471' do
|
153
|
+
let(:number) { 471 }
|
154
|
+
|
155
|
+
it { expect { error.send(:"_#{number}", response) }.to raise_error(RubyRabbitmqJanus::Errors::Janus::Responses::WebRTCState) }
|
156
|
+
end
|
157
|
+
|
158
|
+
context 'when 472' do
|
159
|
+
let(:number) { 472 }
|
160
|
+
|
161
|
+
it { expect { error.send(:"_#{number}", response) }.to raise_error(RubyRabbitmqJanus::Errors::Janus::Responses::NotAcceptingSession) }
|
162
|
+
end
|
163
|
+
|
164
|
+
context 'when 490' do
|
165
|
+
let(:number) { 490 }
|
166
|
+
|
167
|
+
it { expect { error.send(:"_#{number}", response) }.to raise_error(RubyRabbitmqJanus::Errors::Janus::Responses::Unknown) }
|
168
|
+
end
|
169
|
+
|
170
|
+
context 'when error missing' do
|
171
|
+
let(:number) { 418 }
|
172
|
+
|
173
|
+
it { expect { error.send(:"_#{number}", response) }.to raise_error(RubyRabbitmqJanus::Errors::Janus::Responses::Nok) }
|
174
|
+
end
|
175
|
+
end
|
File without changes
|
@@ -0,0 +1,47 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'spec_helper'
|
4
|
+
|
5
|
+
describe RubyRabbitmqJanus::Models::JanusInstance, type: :model,
|
6
|
+
name: :janus_instance do
|
7
|
+
before do
|
8
|
+
instances
|
9
|
+
first
|
10
|
+
end
|
11
|
+
|
12
|
+
let(:model) { described_class }
|
13
|
+
let(:size) { (rand * 5).to_i + 1 }
|
14
|
+
let(:first) { model.first }
|
15
|
+
let(:session_id) { first.session_id }
|
16
|
+
let(:id) { first.id }
|
17
|
+
|
18
|
+
context 'when Janus instances are activated.' do
|
19
|
+
let(:instances) { FactoryBot.create_list(:janus_instance, size) }
|
20
|
+
let(:count_enabled) { size }
|
21
|
+
let(:count_destroyed) { 0 }
|
22
|
+
let(:count_disabled) { 0 }
|
23
|
+
|
24
|
+
include_examples 'when disable an instance'
|
25
|
+
include_examples 'when enable an instance not change'
|
26
|
+
include_examples 'when destroys all disable instance'
|
27
|
+
include_examples 'when search by instance'
|
28
|
+
include_examples 'when search by session'
|
29
|
+
include_examples 'when search instance enabled'
|
30
|
+
include_examples 'when search instance disabled'
|
31
|
+
end
|
32
|
+
|
33
|
+
context 'when Janus instances are disabled.' do
|
34
|
+
let(:instances) { FactoryBot.create_list(:janus_instance, size, enable: false) }
|
35
|
+
let(:count_enabled) { 0 }
|
36
|
+
let(:count_destroyed) { size }
|
37
|
+
let(:count_disabled) { size }
|
38
|
+
|
39
|
+
include_examples 'when disable an instance not change'
|
40
|
+
include_examples 'when enable an instance'
|
41
|
+
include_examples 'when destroys all disable instance'
|
42
|
+
include_examples 'when search by instance'
|
43
|
+
include_examples 'when search by session'
|
44
|
+
include_examples 'when search instance enabled'
|
45
|
+
include_examples 'when search instance disabled'
|
46
|
+
end
|
47
|
+
end
|