freddy 0.5.6 → 0.5.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: 7b44c437c95066c2386f67bc9077fb0194376958
4
- data.tar.gz: 8e4dc3ae45c00ff027a7eccd10609c77f146b715
3
+ metadata.gz: 80d6defa2644f870ae4f4ac27ea804b072f37da2
4
+ data.tar.gz: fc9f2e3229d2eb40c4344a424b4edc38ee26c233
5
5
  SHA512:
6
- metadata.gz: 8fc4ef697700812b814402e02892a5aea60348e6e8550f21de356fe68d22e2c354c785a5f09b18184c61de373b0e03bb203f6aa8f57c4e34d33c1c0dab2fbfcd
7
- data.tar.gz: cd13ca536d3b50a2f650d9bfc6f32639b23273f3233de316ea1e87825aa73d6eebdeec816114bd149c245c9406238dcbb5458777b3bf4042e81be55e1d6bdd44
6
+ metadata.gz: 58b59901aa633d9c782699e0388aa9260f97e4bf3d0ea3af07d3bd1814997a125b30cfaf1edce53f4d2516cd2cb94e4386e6df4b38e345cecca7b4c56a23ce0c
7
+ data.tar.gz: 67ddf7fe5f6007f4dca7d7e757a4b1878622520165d300cc172b16ae2fb7f3c7fb3440cc6d9ff6bfdcfcdca6abe1995b51889d45457455cd0373e34691cd1cd5
@@ -8,7 +8,7 @@ Gem::Specification.new do |spec|
8
8
  else
9
9
  spec.name = "freddy"
10
10
  end
11
- spec.version = '0.5.6'
11
+ spec.version = '0.5.7'
12
12
  spec.authors = ["Urmas Talimaa"]
13
13
  spec.email = ["urmas.talimaa@gmail.com"]
14
14
  spec.description = %q{Messaging API}
@@ -1,11 +1,12 @@
1
1
  class Freddy
2
2
  module Consumers
3
3
  def self.log_receive_event(logger, queue_name, delivery)
4
- if defined?(Logasm) && logger.is_a?(Logasm)
5
- logger.debug "Received message", queue: queue_name, payload: delivery.payload, correlation_id: delivery.correlation_id
6
- else
7
- logger.debug "Received message on #{queue_name} with payload #{delivery.payload} with correlation_id #{delivery.correlation_id}"
8
- end
4
+ logger.debug(
5
+ message: 'Received message',
6
+ queue: queue_name,
7
+ payload: delivery.payload,
8
+ correlation_id: delivery.correlation_id
9
+ )
9
10
  end
10
11
  end
11
12
  end
@@ -1 +1,9 @@
1
+ class Freddy
2
+ module Producers
3
+ def self.log_send_event(logger, payload, destination)
4
+ logger.debug message: 'Sending message', queue: destination, payload: payload
5
+ end
6
+ end
7
+ end
8
+
1
9
  Dir[File.dirname(__FILE__) + '/producers/*.rb'].each(&method(:require))
@@ -9,7 +9,7 @@ class Freddy
9
9
  end
10
10
 
11
11
  def produce(destination, payload, properties)
12
- @logger.debug "Sending message #{payload.inspect} to #{destination}"
12
+ Producers.log_send_event(@logger, payload, destination)
13
13
 
14
14
  properties = properties.merge(
15
15
  routing_key: destination, content_type: CONTENT_TYPE
@@ -10,7 +10,7 @@ class Freddy
10
10
  end
11
11
 
12
12
  def produce(destination, payload, properties)
13
- @logger.debug "Sending message #{payload.inspect} to #{destination}"
13
+ Producers.log_send_event(@logger, payload, destination)
14
14
 
15
15
  properties = properties.merge(routing_key: destination, content_type: CONTENT_TYPE)
16
16
  json_payload = Payload.dump(payload)
@@ -45,9 +45,13 @@ class Freddy
45
45
  )
46
46
  json_payload = Payload.dump(payload)
47
47
 
48
- @logger.debug "Publishing request with payload #{payload.inspect} "\
49
- "to #{destination}, waiting for response on "\
50
- "#{@response_queue.name} with correlation_id #{correlation_id}"
48
+ @logger.debug(
49
+ message: 'Publishing request',
50
+ queue: destination,
51
+ payload: payload,
52
+ response_queue: @response_queue.name,
53
+ correlation_id: correlation_id
54
+ )
51
55
 
52
56
  # Connection adapters handle thread safety for #publish themselves. No
53
57
  # need to lock these.
@@ -24,14 +24,21 @@ describe 'Logging' do
24
24
  it 'logs all consumed messages' do
25
25
  expect(logger1).to have_received(:info).with(/Listening for requests on \S+/)
26
26
  expect(logger1).to have_received(:debug).with(
27
- /Received message on \S+ with payload {:pay=>"load"}/
27
+ message: 'Received message',
28
+ queue: destination,
29
+ payload: payload,
30
+ correlation_id: anything
28
31
  )
29
32
  end
30
33
 
31
34
  it 'logs all produced messages' do
32
35
  expect(logger2).to have_received(:debug).with(/Consuming messages on \S+/)
33
36
  expect(logger2).to have_received(:debug).with(
34
- /Publishing request with payload {:pay=>"load"} to \S+, waiting for response on amq.gen-\S+ with correlation_id .*/
37
+ message: 'Publishing request',
38
+ queue: destination,
39
+ payload: payload,
40
+ response_queue: anything,
41
+ correlation_id: anything
35
42
  )
36
43
  end
37
44
  end
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.5.6
4
+ version: 0.5.7
5
5
  platform: ruby
6
6
  authors:
7
7
  - Urmas Talimaa
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-04-26 00:00:00.000000000 Z
11
+ date: 2016-07-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bundler
@@ -136,7 +136,6 @@ files:
136
136
  - lib/freddy/timeout_error.rb
137
137
  - lib/freddy/utils.rb
138
138
  - spec/freddy/consumers/respond_to_consumer_spec.rb
139
- - spec/freddy/consumers_spec.rb
140
139
  - spec/freddy/error_response_spec.rb
141
140
  - spec/freddy/freddy_spec.rb
142
141
  - spec/freddy/message_handler_spec.rb
@@ -167,13 +166,12 @@ required_rubygems_version: !ruby/object:Gem::Requirement
167
166
  version: '0'
168
167
  requirements: []
169
168
  rubyforge_project:
170
- rubygems_version: 2.4.5.1
169
+ rubygems_version: 2.4.8
171
170
  signing_key:
172
171
  specification_version: 4
173
172
  summary: API for inter-application messaging supporting acknowledgements and request-response
174
173
  test_files:
175
174
  - spec/freddy/consumers/respond_to_consumer_spec.rb
176
- - spec/freddy/consumers_spec.rb
177
175
  - spec/freddy/error_response_spec.rb
178
176
  - spec/freddy/freddy_spec.rb
179
177
  - spec/freddy/message_handler_spec.rb
@@ -1,43 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Freddy::Consumers do
4
- describe '.log_receive_event' do
5
- subject { described_class.log_receive_event(logger, queue_name, delivery) }
6
-
7
- let(:queue_name) { 'salemove' }
8
- let(:delivery) do
9
- instance_double(Freddy::Delivery,
10
- payload: {key: 'value'},
11
- correlation_id: 'a1b2'
12
- )
13
- end
14
-
15
- context 'when configured with logasm logger' do
16
- let(:logger) { logasm_class.new }
17
- let(:logasm_class) { Class.new }
18
-
19
- before do
20
- stub_const('::Logasm', logasm_class)
21
- end
22
-
23
- it 'logs the received event' do
24
- expect(logger).to receive(:debug).with('Received message',
25
- queue: 'salemove', payload: {key: 'value'}, correlation_id: 'a1b2'
26
- )
27
-
28
- subject
29
- end
30
- end
31
-
32
- context 'when configured with regular logger' do
33
- let(:logger) { Logger.new('/dev/null') }
34
-
35
- it 'logs the received event' do
36
- expect(logger).to receive(:debug)
37
- .with('Received message on salemove with payload {:key=>"value"} with correlation_id a1b2')
38
-
39
- subject
40
- end
41
- end
42
- end
43
- end