freddy 0.3.3 → 0.3.4

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: 0d677aed926ebfba37c90931e9cf1945e68b9b25
4
- data.tar.gz: cf670f4b31d6d15434edf9f53876cf447f6a4b5a
3
+ metadata.gz: bc5a587ccd4505868a43c8444abdbb376d30e124
4
+ data.tar.gz: f4f09ae1d1f046689e71245b9170cf9154fa0946
5
5
  SHA512:
6
- metadata.gz: 71e4c1cfe3a93a877fd05f04962c2c63b14e9bf9d5b14bbef0657855e649d30aa90c152c224d059030932e98c5e7b80c7474cf8238eb6425965ed138f9d62837
7
- data.tar.gz: 2f84c367f1b5d2bfb6108962343c92ef8dc160479bd79d14b1bdf166ef6f4fa9608a5a71e9299664a9b00b09cab1102f2e1b93c859d383544099ac2c27da1e8b
6
+ metadata.gz: c9e6c129c97c63e92abdb3449f127fdb3c64dcf6b73a385b3bd3acd57682f8d3ceb30850e3a38a3431cc7bd61408f2177db9f861547beed33ff58e9babc7b4ba
7
+ data.tar.gz: bdcc1cbb44b821cda0494177c326eab270f254e2c0cb8988bd620f3dbb221967788c2ec58bbe23c87f416fd2f85d4d9724e80d242868fb0c47662cce64a71ec9
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- freddy (0.3.3)
4
+ freddy (0.3.4)
5
5
  bunny (= 1.6.3)
6
6
  hamster (~> 1.0.1.pre.rc3)
7
7
  symbolizer
data/README.md CHANGED
@@ -49,13 +49,15 @@ response = freddy.deliver_with_response(destination, message, timeout: 4, delete
49
49
  ```
50
50
 
51
51
  #### Errors
52
- `deliver_with_response` raises an error if an error is returned. This can be handled by rescuing from `Freddy::ErrorResponse` as:
52
+ `deliver_with_response` raises an error if an error is returned. This can be handled by rescuing from `Freddy::InvalidRequestError` and `Freddy::TimeoutError` as:
53
53
  ```ruby
54
54
  begin
55
55
  response = freddy.deliver_with_response 'Q', {}
56
56
  # ...
57
- rescue Freddy::ErrorResponse => e
58
- e.response # => { error: 'Timed out waiting for response' }
57
+ rescue Freddy::InvalidRequestError => e
58
+ e.response # => { error: 'InvalidRequestError', message: 'Some error message' }
59
+ rescue Freddy::TimeoutError => e
60
+ e.response # => { error: 'RequestTimeout', message: 'Timed out waiting for response' }
59
61
  ```
60
62
 
61
63
  ## Responding to messages
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
4
 
5
5
  Gem::Specification.new do |spec|
6
6
  spec.name = "freddy"
7
- spec.version = '0.3.3'
7
+ spec.version = '0.3.4'
8
8
  spec.authors = ["Urmas Talimaa"]
9
9
  spec.email = ["urmas.talimaa@gmail.com"]
10
10
  spec.description = %q{Messaging API}
@@ -16,6 +16,12 @@ class Freddy
16
16
  end
17
17
  end
18
18
 
19
+ class InvalidRequestError < ErrorResponse
20
+ end
21
+
22
+ class TimeoutError < ErrorResponse
23
+ end
24
+
19
25
  FREDDY_TOPIC_EXCHANGE_NAME = 'freddy-topic'.freeze
20
26
 
21
27
  def self.format_backtrace(backtrace)
@@ -35,7 +35,8 @@ class Freddy
35
35
  message = "Request #{correlation_id} timed out waiting response from #{request[:destination]} with timeout #{request[:timeout]}"
36
36
  @logger.warn message
37
37
  Freddy.notify 'RequestTimeout', message, request: correlation_id, destination: request[:destination], timeout: request[:timeout]
38
- request[:callback].call({error: 'Timed out waiting for response'}, nil)
38
+
39
+ request[:callback].call({error: 'RequestTimeout', message: 'Timed out waiting for response'}, nil)
39
40
  end
40
41
  end
41
42
  end
@@ -12,8 +12,10 @@ class Freddy
12
12
  sleep 0.001 until filled?
13
13
  end
14
14
 
15
- if !@delivery || @delivery.properties[:type] == 'error'
16
- raise ErrorResponse.new(@response)
15
+ if @response[:error] == 'RequestTimeout'
16
+ raise TimeoutError.new(@response)
17
+ elsif !@delivery || @delivery.properties[:type] == 'error'
18
+ raise InvalidRequestError.new(@response)
17
19
  else
18
20
  @response
19
21
  end
@@ -60,7 +60,7 @@ describe Freddy do
60
60
 
61
61
  expect {
62
62
  freddy.deliver_with_response(destination, payload)
63
- }.to raise_error(Freddy::ErrorResponse) {|error|
63
+ }.to raise_error(Freddy::InvalidRequestError) {|error|
64
64
  expect(error.response).to eq(error: 'not today')
65
65
  }
66
66
  end
@@ -88,7 +88,7 @@ describe Freddy do
88
88
 
89
89
  expect {
90
90
  freddy.deliver_with_response(destination2, payload)
91
- }.to raise_error(Freddy::ErrorResponse)
91
+ }.to raise_error(Freddy::InvalidRequestError)
92
92
  end
93
93
 
94
94
  context 'when queue does not exist' do
@@ -97,7 +97,7 @@ describe Freddy do
97
97
  Timeout::timeout(0.5) do
98
98
  expect {
99
99
  freddy.deliver_with_response(destination, {a: 'b'}, timeout: 3)
100
- }.to raise_error(Freddy::ErrorResponse) {|error|
100
+ }.to raise_error(Freddy::InvalidRequestError) {|error|
101
101
  expect(error.response).to eq(error: 'Specified queue does not exist')
102
102
  }
103
103
  end
@@ -113,8 +113,8 @@ describe Freddy do
113
113
 
114
114
  expect {
115
115
  freddy.deliver_with_response(destination, {a: 'b'}, timeout: 0.1)
116
- }.to raise_error(Freddy::ErrorResponse) {|error|
117
- expect(error.response).to eq(error: 'Timed out waiting for response')
116
+ }.to raise_error(Freddy::TimeoutError) {|error|
117
+ expect(error.response).to eq(error: 'RequestTimeout', message: 'Timed out waiting for response')
118
118
  }
119
119
  end
120
120
 
@@ -126,7 +126,7 @@ describe Freddy do
126
126
 
127
127
  expect {
128
128
  freddy.deliver_with_response(destination, {}, timeout: 0.1)
129
- }.to raise_error(Freddy::ErrorResponse)
129
+ }.to raise_error(Freddy::TimeoutError)
130
130
  default_sleep # to ensure everything is properly cleaned
131
131
 
132
132
  processed_after_timeout = false
@@ -145,7 +145,7 @@ describe Freddy do
145
145
 
146
146
  expect {
147
147
  freddy.deliver_with_response(destination, {}, timeout: 0.1, delete_on_timeout: false)
148
- }.to raise_error(Freddy::ErrorResponse)
148
+ }.to raise_error(Freddy::TimeoutError)
149
149
  default_sleep # to ensure everything is properly cleaned
150
150
 
151
151
  processed_after_timeout = false
@@ -8,7 +8,7 @@ describe 'Concurrency' do
8
8
  begin
9
9
  result = freddy.deliver_with_response 'Concurrency2', msg: 'noop'
10
10
  msg_handler.success(result)
11
- rescue Freddy::ErrorResponse => e
11
+ rescue Freddy::InvalidRequestError => e
12
12
  msg_handler.error(e.response)
13
13
  end
14
14
  end
@@ -17,7 +17,7 @@ describe 'Concurrency' do
17
17
  begin
18
18
  result = freddy.deliver_with_response 'Concurrency3', msg: 'noop'
19
19
  msg_handler.success(result)
20
- rescue Freddy::ErrorResponse => e
20
+ rescue Freddy::InvalidRequestError => e
21
21
  msg_handler.error(e.response)
22
22
  end
23
23
  end
@@ -29,7 +29,7 @@ describe 'Concurrency' do
29
29
  result =
30
30
  begin
31
31
  freddy.deliver_with_response 'Concurrency1', msg: 'noop'
32
- rescue Freddy::ErrorResponse => e
32
+ rescue Freddy::InvalidRequestError => e
33
33
  e.response
34
34
  end
35
35
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: freddy
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.3
4
+ version: 0.3.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Urmas Talimaa
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-07-07 00:00:00.000000000 Z
11
+ date: 2015-07-28 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -137,7 +137,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
137
137
  version: '0'
138
138
  requirements: []
139
139
  rubyforge_project:
140
- rubygems_version: 2.2.2
140
+ rubygems_version: 2.4.3
141
141
  signing_key:
142
142
  specification_version: 4
143
143
  summary: API for inter-application messaging supporting acknowledgements and request-response