ruby_rabbitmq_janus 1.2.7 → 1.2.8
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/rrj/errors/tools/config.rb +0 -1
- data/lib/rrj/info.rb +1 -1
- data/lib/rrj/janus/processus/concurrency.rb +2 -3
- data/lib/rrj/janus/processus/event.rb +3 -2
- data/lib/rrj/janus/processus/keepalive.rb +24 -19
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f476513f5e5d4c4e80d79a6744d57742d50c523e
|
4
|
+
data.tar.gz: 929e04e9429877f21cdedaa4ad7b5461e8ddf54a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 77f0c437d77862d84f9492e27ab27f497fe674fd1ce419d670a21944cf920b21af3a49f3cdcec22f500b8d47b6ce045e5bc4c02c7e8fdefdd1fa2ad8590fd5c7
|
7
|
+
data.tar.gz: 90bf97502d8770c33bc5383969eb53e7968469f11d4509b6e2a17b20beb509dc4ddec6d240ff17d98a98773ebcbb6fcf859801ecf2ca75ee6d62aa530ac12b62
|
@@ -16,7 +16,6 @@ module RubyRabbitmqJanus
|
|
16
16
|
class FileNotFound < Config
|
17
17
|
# Initialize a error for Config class if file don't exist.
|
18
18
|
# It's a fatal error
|
19
|
-
# @param [String] file Is a file path
|
20
19
|
def initialize
|
21
20
|
super 'Error for configuration file, does on exist.', :fatal
|
22
21
|
end
|
data/lib/rrj/info.rb
CHANGED
@@ -9,7 +9,7 @@ module RubyRabbitmqJanus
|
|
9
9
|
# # Class for manage threads
|
10
10
|
#
|
11
11
|
# @abstract Manage thread in this gem for keepalive message and listen
|
12
|
-
#
|
12
|
+
# standard queue.
|
13
13
|
class Concurrency
|
14
14
|
# Initialize class with elements for thread communication
|
15
15
|
def initialize
|
@@ -29,8 +29,7 @@ module RubyRabbitmqJanus
|
|
29
29
|
@rabbit.close
|
30
30
|
end
|
31
31
|
|
32
|
-
|
33
|
-
attr_reader :thread, :lock, :condition
|
32
|
+
attr_reader :thread, :lock, :condition, :rabbit
|
34
33
|
end
|
35
34
|
end
|
36
35
|
end
|
@@ -14,10 +14,11 @@ module RubyRabbitmqJanus
|
|
14
14
|
class Event < Concurrency
|
15
15
|
include Singleton
|
16
16
|
|
17
|
-
# Create a
|
17
|
+
# Create a thread for execute a block code in a thread
|
18
18
|
#
|
19
19
|
# @param [Proc] block Block code for execute action when queue
|
20
|
-
# standard 'from-janus' receive a message.
|
20
|
+
# standard 'from-janus' receive a message.This block is sending to
|
21
|
+
# publisher created for this thread.
|
21
22
|
#
|
22
23
|
# @return [Thread] It's a thread who listen queue and execute action
|
23
24
|
def run(&block)
|
@@ -5,31 +5,39 @@ module RubyRabbitmqJanus
|
|
5
5
|
module Concurrencies
|
6
6
|
# @author VAILLANT Jeremy <jeremy.vaillant@dazzl.tv>
|
7
7
|
|
8
|
-
# # Manage
|
8
|
+
# # Manage keepalive message
|
9
9
|
#
|
10
|
-
# Create a thread for sending keepalive to session
|
11
|
-
# instanciate gem
|
10
|
+
# Create a thread for sending a message with type keepalive to session
|
11
|
+
# created by this instanciate gem
|
12
|
+
#
|
13
|
+
# @see https://ruby-doc.org/stdlib-2.4.0/libdoc/singleton/rdoc/Singleton.html
|
12
14
|
class Keepalive < Concurrency
|
13
15
|
include Singleton
|
14
16
|
|
15
|
-
#
|
17
|
+
# Initialize a singleton object for sending keepalive to janus
|
16
18
|
def initialize
|
17
|
-
@
|
19
|
+
@pub = @session = nil
|
18
20
|
super
|
19
21
|
end
|
20
22
|
|
23
|
+
# Give a session Integer created when this gem is intanciate.
|
24
|
+
# Is waiting a thread return a response to message created sending.
|
25
|
+
#
|
26
|
+
# @example Ask session
|
27
|
+
# Keepalive.instance.session
|
28
|
+
# => 852803383803249
|
21
29
|
# @return [Fixnum] Identifier to session created by Janus
|
22
30
|
def session
|
23
31
|
lock.synchronize do
|
24
32
|
condition.wait(lock)
|
25
|
-
|
33
|
+
@session
|
26
34
|
end
|
27
35
|
end
|
28
36
|
|
29
37
|
private
|
30
38
|
|
31
39
|
def transaction_running
|
32
|
-
@
|
40
|
+
@session = find_session
|
33
41
|
synchronize
|
34
42
|
create_loop_session
|
35
43
|
rescue => error
|
@@ -46,30 +54,27 @@ module RubyRabbitmqJanus
|
|
46
54
|
|
47
55
|
def loop_session(time_to_live)
|
48
56
|
sleep time_to_live
|
49
|
-
@
|
50
|
-
Tools::Log.instance.info "Keepalive for #{
|
57
|
+
@pub.publish(message_keepalive)
|
58
|
+
Tools::Log.instance.info "Keepalive for #{@session}"
|
51
59
|
end
|
52
60
|
|
53
61
|
def create_session
|
54
|
-
@
|
55
|
-
|
56
|
-
@publisher.publish(Janus::Messages::Standard.new('base::create'))
|
62
|
+
@pub = Rabbit::Publisher::PublishExclusive.new(rabbit.channel, '')
|
63
|
+
@pub.publish(Janus::Messages::Standard.new('base::create'))
|
57
64
|
rescue => error
|
58
65
|
raise Errors::KeepaliveCreateSession, error
|
59
66
|
end
|
60
67
|
|
61
|
-
def running_session
|
62
|
-
@response.session
|
63
|
-
rescue => error
|
64
|
-
raise Errors::KeepaliveSessionReturn, error
|
65
|
-
end
|
66
|
-
|
67
68
|
def message_keepalive
|
68
|
-
opt = { 'session_id' =>
|
69
|
+
opt = { 'session_id' => @session }
|
69
70
|
Janus::Messages::Standard.new('base::keepalive', opt)
|
70
71
|
rescue => error
|
71
72
|
raise Errors::KeepaliveMessage, error
|
72
73
|
end
|
74
|
+
|
75
|
+
def find_session
|
76
|
+
Janus::Responses::Standard.new(create_session).to_hash['data']['id']
|
77
|
+
end
|
73
78
|
end
|
74
79
|
end
|
75
80
|
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: 1.2.
|
4
|
+
version: 1.2.8
|
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-01-
|
11
|
+
date: 2017-01-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|