ruby_rabbitmq_janus 3.0.0.pre.330 → 3.0.0.pre.334

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
  SHA256:
3
- metadata.gz: 1c3a260ec4a0e7f1f1ac58fe41150a3438582ef410a8725f797b4f86132ab1d2
4
- data.tar.gz: a7ecb8c35bc54dd49522ad1c9b932e90c36d7a3d2706a18d002d7309140d5246
3
+ metadata.gz: dab52d2ea0ff5412d2747cc0a35d0f5ad2d4e39fbe5080df7f7b6909781d152e
4
+ data.tar.gz: 673e03c92bd18201acc0d25eb001dc0f9876b654991c4111229bebf154f53b41
5
5
  SHA512:
6
- metadata.gz: e704f0bc5948f2e12fa0ddceaa2b8aa9d969847815afce0e86d58c531492b7bfbb03a3ac95ed3f62e05c2644187d7bc6590a3590f3282844769c42f55f568904
7
- data.tar.gz: de779a12355aadd0f0d693f902bd4741d8c989b04efbfaaa4dc03136e724a7ec573cde6c46beb53c92da7a334508c7dbf94fbfc96c66793049cf541f78870053
6
+ metadata.gz: 9034e88142324ef2de0aaee27db832d80fff227fe62e31c06eef8c72ca73f4f152632e5c472118368a74b54a1e02bc64844b5db7201ad2b1e8899fda03c3f328
7
+ data.tar.gz: '068051edf6efdcaf97658f503bb4c6f86463e0483398b61e49b0f0e8af5187d551f7876a31c874e7b92ca96f508260caaab33dc5170ecdc0cde3fb065303aee2'
@@ -18,6 +18,13 @@ module RubyRabbitmqJanus
18
18
  end
19
19
  end
20
20
 
21
+ # Error when transaction hs no block
22
+ class MissingAction < RubyRabbitmqJanus::Errors::Rabbit::BaseConnect
23
+ def initialize
24
+ super 'Transaction failed, missing block'
25
+ end
26
+ end
27
+
21
28
  # Error for Rabbit::Connect#transaction_short
22
29
  class TransactionShort < RubyRabbitmqJanus::Errors::Rabbit::BaseConnect
23
30
  def initialize(error)
@@ -10,13 +10,15 @@ module RubyRabbitmqJanus
10
10
  class Connect
11
11
  # Initialize connection to server RabbitMQ
12
12
  def initialize
13
- @rabbit = Bunny.new(Tools::Config.instance.server_settings)
13
+ @rabbit = Bunny.new(bunny_conf)
14
14
  rescue => exception
15
15
  raise Errors::Rabbit::Connect::Initialize, exception
16
16
  end
17
17
 
18
18
  # Create an transaction with rabbitmq and close after response is received
19
19
  def transaction_short
20
+ raise Errors::Rabbit::Connect::MissingAction unless block_given?
21
+
20
22
  response = transaction_long { yield }
21
23
  close
22
24
  response
@@ -26,6 +28,8 @@ module RubyRabbitmqJanus
26
28
 
27
29
  # Create an transaction with rabbitmq and not close
28
30
  def transaction_long
31
+ raise Errors::Rabbit::Connect::MissingAction unless block_given?
32
+
29
33
  Timeout.timeout(10) do
30
34
  start
31
35
  yield
@@ -54,6 +58,12 @@ module RubyRabbitmqJanus
54
58
  rescue => exception
55
59
  raise Errors::Rabbit::Connect::Channel, exception
56
60
  end
61
+
62
+ private
63
+
64
+ def bunny_conf
65
+ Tools::Config.instance.server_settings.merge(connection_timeout: 5)
66
+ end
57
67
  end
58
68
  end
59
69
  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: 3.0.0.pre.330
4
+ version: 3.0.0.pre.334
5
5
  platform: ruby
6
6
  authors:
7
7
  - VAILLANT Jeremy
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-11-28 00:00:00.000000000 Z
11
+ date: 2019-12-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activerecord