ruby_rabbitmq_janus 1.1.6 → 1.1.7

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 16fab11a75e786cc85e96f0a4383cfdcec00a414
4
- data.tar.gz: cc84f9e8c559eea2b01e93136b61b00ed4c1a378
3
+ metadata.gz: 5f021ba350f01ec31ec3a312852fba9aad13bc3d
4
+ data.tar.gz: 4c02fb1a5cd2bb555744412432a858cb427c19b2
5
5
  SHA512:
6
- metadata.gz: 4799b7cd67bca8e79daf60866f775dc0b37a1fc8959accff6ec17656ad41fd92727edfb619fad4164017aaea01e9add3d1959a792fcfe0af26d13d2491b9f3d5
7
- data.tar.gz: fc3a1db3b8e6ca46f92aeb778786a84d21e064b87bbb46c6b69cea1031d2ec230ea6765054fea1339d975fc80edc5dcd36846a56870aadd7f5bbd6eb1f9c470a
6
+ metadata.gz: 8e06d5e9d0fa8918e3fb05418591a1359cd745a2b5b6115131aa1065bbc58a24b9738064d107790820a688d90d858cabf4ed5fcc3ce754900141d0a0458c4eb0
7
+ data.tar.gz: 34b60a33db21da0d73fd20f850af13d0a8974d69e7ce34c2f449f2f17d8a63c565180bc51659a4fd2af5c572d7ce283fad93e646618a4d6ec833712fa2455ca7
data/CHANGELOG.md CHANGED
@@ -5,10 +5,14 @@ All notable changes to this project will be documented in this file.
5
5
  The format is based on [Keep a Changelog](http://keepachangelog.com/)
6
6
  and this project adheres to [Semantic Versioning](http://semver.org/).
7
7
 
8
+ ## [1.1.7] - 2016-11-28
9
+ ### Changed
10
+ - Use handle if is given in arguments for handle_message_simple
11
+ - Update default initializer with comments and fix rake execution
12
+
8
13
  ## [1.1.6] - 2016-11-24
9
14
  ### Added
10
15
  - Add this changelog file
11
16
 
12
17
  ### Changed
13
- - Update in config file log level field reading upcase or downcase is acceptable
14
-
18
+ - Update in config file log level field reading upcase or downcase is acceptable
@@ -9,9 +9,32 @@ module RubyRabbitmqJanus
9
9
  # Create an initializer
10
10
  def copy_initializer
11
11
  initializer 'ruby_rabbitmq_janus.rb' do
12
- "# frozen_string_literal: true\n\n" \
13
- "::RRJ = RubyRabbitmqJanus::RRJ.new\n"\
14
- '::JanusEvents = RubyRabbitmqJanus::Janus::Concurrencies::Event.instance'
12
+ <<-INIT
13
+ # frozen_string_literal: true
14
+
15
+ # This test disable this gems execution when you running an task with rake
16
+ unless File.basename($PROGRAM_NAME) == 'rake'
17
+ # Write your methods for listening standar queue here
18
+ #
19
+ # Example :
20
+ # action_events = lambda do |reason, data|
21
+ # logger.debug 'Execute block code with reason :'
22
+ # logger.debug reason
23
+ # logger.debug --
24
+ # logger.debug data
25
+ # end
26
+
27
+ Rails.configuration.after_initialize do
28
+ # Initialize a gem and create an session with a keepalive
29
+ ::RRJ = RubyRabbitmqJanus::RRJ.new
30
+
31
+ # If you want listen a standard queue and execute an block code uncomment
32
+ # this line and craete an method sendind to run
33
+ # ::JEvents = RubyRabbitmqJanus::Janus::Concurrencies::Event.instance
34
+ # JEvents.run(&action_events)
35
+ end
36
+ end
37
+ INIT
15
38
  end
16
39
  end
17
40
  end
data/lib/rrj/info.rb CHANGED
@@ -3,7 +3,7 @@
3
3
  # Define constant to gem.
4
4
  module RubyRabbitmqJanus
5
5
  # Define version to gem
6
- VERSION = '1.1.6'
6
+ VERSION = '1.1.7'
7
7
 
8
8
  # Define a summary description to gem
9
9
  SUMMARY = 'Ruby RabbitMQ Janus'
data/lib/rrj/init.rb CHANGED
@@ -17,6 +17,7 @@ module RubyRabbitmqJanus
17
17
  # @!attribute [r] session
18
18
  # @return [Fixnum] Renturn an session number created in instanciate gem
19
19
  # :reek:BooleanParameter and :reek:ControlParameter and :reek:DataClump
20
+ # :reek:LongParameterList and :reek:TooManyStatements
20
21
  class RRJ
21
22
  attr_reader :session
22
23
 
@@ -133,9 +134,10 @@ module RubyRabbitmqJanus
133
134
  # }
134
135
  # RubyRabbitmqJanus::RRJ.new.handle_message_simple('peer::trickle', candidate)
135
136
  # #=> { 'janus' => 'trickle', ..., 'candidate' => { 'completed' : true } } }
136
- def handle_message_simple(type, replace = {}, add = {})
137
+ def handle_message_simple(type, replace = {}, add = {}, exclusive = false)
138
+ handle = replace.include?('handle_id') ? replace['handle_id'] : 0
137
139
  @transaction = Janus::Transactions::Handle.new(@session)
138
- @transaction.handle_connect_and_stop(false) do
140
+ @transaction.handle_connect_and_stop(exclusive, handle) do
139
141
  message_handle(type, replace, add).for_plugin
140
142
  end
141
143
  rescue => error
@@ -5,6 +5,7 @@ module RubyRabbitmqJanus
5
5
  module Transactions
6
6
  # @author VAILLANT Jeremy <jeremy.vaillant@dazzl.tv>
7
7
  # This class work with janus and send a series of message
8
+ # :reek:TooManyStatements
8
9
  class Handle < Session
9
10
  # Inistialize transaction handle
10
11
  def initialize(session)
@@ -24,11 +25,11 @@ module RubyRabbitmqJanus
24
25
 
25
26
  # Initialize connection to Rabbit and Janus and close after sending an received
26
27
  # a response
27
- def handle_connect_and_stop(exclusive)
28
+ def handle_connect_and_stop(exclusive, sender)
28
29
  @exclusive = exclusive
29
30
  rabbit.transaction_short do
30
31
  choose_queue(exclusive)
31
- create_handle
32
+ sender.eql?(0) ? create_handle : connect_handle(sender)
32
33
  yield
33
34
  end
34
35
  end
@@ -48,13 +49,19 @@ module RubyRabbitmqJanus
48
49
 
49
50
  private
50
51
 
51
- # Associate handle to transaction
52
+ # Create an handle for transaction
52
53
  def create_handle
53
54
  Tools::Log.instance.info 'Create an handle'
54
55
  msg = Janus::Messages::Standard.new('base::attach', 'session_id' => session)
55
56
  @handle = send_a_message_exclusive { msg }
56
57
  end
57
58
 
59
+ # Connect to handle
60
+ def connect_handle(sender)
61
+ Tools::Log.instance.info 'Connect an handle'
62
+ @handle = sender
63
+ end
64
+
58
65
  # Send a messaeg in exclusive queue
59
66
  def send_a_message_exclusive
60
67
  Janus::Responses::Standard.new(read_response_exclusive { yield }).sender
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.1.6
4
+ version: 1.1.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - VAILLANT Jeremy
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-11-24 00:00:00.000000000 Z
11
+ date: 2016-11-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler