ruby_rabbitmq_janus 1.2.7 → 1.2.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ca155bd8711514b7bd8c4e10a537fb048d3b8c00
4
- data.tar.gz: c585796fb9ebf333f52ad41f5d78d7b54895a1ec
3
+ metadata.gz: f476513f5e5d4c4e80d79a6744d57742d50c523e
4
+ data.tar.gz: 929e04e9429877f21cdedaa4ad7b5461e8ddf54a
5
5
  SHA512:
6
- metadata.gz: 7b1e377ec9581fdce7f6bbfa78a6981cb87f27364a701d075582f7d6bffceb5f1c663637909e43b2e74798e2791c0bd20fd6bff2e6bab9c42579743fe4901797
7
- data.tar.gz: 8f09f80f1390e3e1d57367c2b72f52e25af4d206b104c52481f7e5b6f6c1e537a13401f5addaa3b7b76d04f0b6955666573632e7a85a9a9ee23a0e028ca8a1cb
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
@@ -5,7 +5,7 @@
5
5
  # Define constant to gem.
6
6
  module RubyRabbitmqJanus
7
7
  # Define version to gem
8
- VERSION = '1.2.7'
8
+ VERSION = '1.2.8'
9
9
 
10
10
  # Name to gem
11
11
  GEM_NAME = 'ruby_rabbitmq_janus'
@@ -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
- # standard queue.
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
- attr_accessor :rabbit, :publish
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 thred for execute a block code in a thread
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 sending keepalive message
8
+ # # Manage keepalive message
9
9
  #
10
- # Create a thread for sending keepalive to session created by this
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
- # Create a thread
17
+ # Initialize a singleton object for sending keepalive to janus
16
18
  def initialize
17
- @response = @publisher = nil
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
- running_session
33
+ @session
26
34
  end
27
35
  end
28
36
 
29
37
  private
30
38
 
31
39
  def transaction_running
32
- @response = Janus::Responses::Standard.new(create_session)
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
- @publisher.publish(message_keepalive)
50
- Tools::Log.instance.info "Keepalive for #{running_session}"
57
+ @pub.publish(message_keepalive)
58
+ Tools::Log.instance.info "Keepalive for #{@session}"
51
59
  end
52
60
 
53
61
  def create_session
54
- @publisher = Rabbit::Publisher::PublishExclusive.new(rabbit.channel,
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' => running_session }
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.7
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-24 00:00:00.000000000 Z
11
+ date: 2017-01-27 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler