magellan-rails 0.2.2 → 0.2.3

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: 8c421c287c6fa5f5c8f5b6ef25b7b3f99bfae56e
4
- data.tar.gz: 0c895a7553fa8799cd237631a549ebd8c44206b5
3
+ metadata.gz: 63e5b0203bac9edc86ff8a7c38a4d5614d4cb885
4
+ data.tar.gz: cc46775047760890bfc4b4090dea5ee33d8fbf00
5
5
  SHA512:
6
- metadata.gz: 36dfd7b680d8689dc06111cb67a366946fc4b0a9385a17f34d0af9dd0d5672de56bbc877c21fa1f2b4f9459585378d062bc2b23d39313b1860d00542fb380053
7
- data.tar.gz: 1e9474777f528152bb2913dbb43eb750c65ebb7c827d3ebc058b81fc0c7bdbb4b39d8166dd5ad76d0e991b1848cc84c3da4796f9039e948c9182e9474b295cc8
6
+ metadata.gz: 6a8f418c06a1be76956354ad59db62ca43d256e1241ebeb06ee6c6fbd964552d56977d3cee49d1900c4d716a54fc1b4af6d62b864b8edc9e909506361bdbd74f
7
+ data.tar.gz: cf79d0fe416b92487b12b4f8e762614e3b4689b87a3db5cb7cf29011763ed9199e0638e479a7f85f520a7ec5ce38b5ca79e2e5e768094838dac0a30eba032a32
@@ -14,8 +14,11 @@ class Magellan::Rails::Response
14
14
  @body = ''
15
15
  @body_encoding = :plain
16
16
  body_proxy = response[2]
17
- body_proxy.each{|b| @body << b}
18
- body_proxy.close
17
+ begin
18
+ body_proxy.each{|b| @body << b}
19
+ ensure
20
+ body_proxy.close if body_proxy.respond_to?(:close)
21
+ end
19
22
  end
20
23
 
21
24
  def to_message
@@ -1,5 +1,5 @@
1
1
  module Magellan
2
2
  module Rails
3
- VERSION = "0.2.2"
3
+ VERSION = "0.2.3"
4
4
  end
5
5
  end
@@ -27,11 +27,14 @@ class Magellan::Worker::Executor
27
27
  case version
28
28
  when 1
29
29
  request_method = request_message["headers"]["Method"]
30
+ request_id = request_message["headers"]["Magellan-Request-Id"]
30
31
  when 2
31
32
  request_method = request_message["env"]["METHOD"]
33
+ request_id = request_message["env"]["REQUEST_ID"]
32
34
  else
33
35
  raise "Unsupported request format version: #{version}. Please update magellan-rails."
34
36
  end
37
+ Magellan.logger.info("Magellan requested with `#{request_id}`")
35
38
  case request_method
36
39
  when /\Apublish\z/i
37
40
  subscriber_executor.execute(request_message)
@@ -1,6 +1,7 @@
1
1
  # coding: utf-8
2
2
 
3
3
  require "spec_helper"
4
+ require "securerandom"
4
5
 
5
6
  describe Magellan::Worker::Executor do
6
7
 
@@ -17,18 +18,20 @@ describe Magellan::Worker::Executor do
17
18
  e.instance_variable_set :@subscriber_executor, subscriber_executor
18
19
  end
19
20
  end
21
+ let(:request_id) { SecureRandom.uuid }
20
22
  before do
21
23
  allow_any_instance_of(Magellan::Worker::Executor).to receive(:require)
22
24
  end
23
25
 
24
26
  context "v1" do
25
- let(:request_obj) do { "headers" => { "Method" => @method, "Path-Info" => "topic" }, "body" => "payload" } end
27
+ let(:request_obj) do { "headers" => { "Method" => @method, "Path-Info" => "topic", "Magellan-Request-Id" => request_id }, "body" => "payload" } end
26
28
  context "GET" do
27
29
  before do
28
30
  @method = "GET"
29
31
  expect(rails_executor).to receive(:execute).with(reply_to, correlation_id, delivery_tag, request_obj).and_return(:result)
30
32
  end
31
33
  it do
34
+ expect(Magellan.logger).to receive(:info).with("Magellan requested with `#{request_id}`").once
32
35
  expect(executor.execute(reply_to, correlation_id, delivery_tag, request_obj)).to eql(:result)
33
36
  end
34
37
  end
@@ -38,18 +41,20 @@ describe Magellan::Worker::Executor do
38
41
  expect(subscriber_executor).to receive(:execute).with(request_obj).and_return(:result)
39
42
  end
40
43
  it do
44
+ expect(Magellan.logger).to receive(:info).with("Magellan requested with `#{request_id}`").once
41
45
  expect(executor.execute(reply_to, correlation_id, delivery_tag, request_obj)).to eql(:result)
42
46
  end
43
47
  end
44
48
  end
45
49
  context "v2" do
46
- let(:request_obj) do { "v" => 2, "env" => { "METHOD" => @method, "PATH_INFO" => "topic" }, "headers" => {}, "body" => "payload" } end
50
+ let(:request_obj) do { "v" => 2, "env" => { "METHOD" => @method, "PATH_INFO" => "topic", "REQUEST_ID" => request_id }, "headers" => {}, "body" => "payload" } end
47
51
  context "GET" do
48
52
  before do
49
53
  @method = "GET"
50
54
  expect(rails_executor).to receive(:execute).with(reply_to, correlation_id, delivery_tag, request_obj).and_return(:result)
51
55
  end
52
56
  it do
57
+ expect(Magellan.logger).to receive(:info).with("Magellan requested with `#{request_id}`").once
53
58
  expect(executor.execute(reply_to, correlation_id, delivery_tag, request_obj)).to eql(:result)
54
59
  end
55
60
  end
@@ -59,6 +64,7 @@ describe Magellan::Worker::Executor do
59
64
  expect(subscriber_executor).to receive(:execute).with(request_obj).and_return(:result)
60
65
  end
61
66
  it do
67
+ expect(Magellan.logger).to receive(:info).with("Magellan requested with `#{request_id}`").once
62
68
  expect(executor.execute(reply_to, correlation_id, delivery_tag, request_obj)).to eql(:result)
63
69
  end
64
70
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: magellan-rails
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.2
4
+ version: 0.2.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Yuuki Noguchi
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-02-04 00:00:00.000000000 Z
11
+ date: 2015-03-09 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: railties
@@ -169,7 +169,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
169
169
  version: '0'
170
170
  requirements: []
171
171
  rubyforge_project:
172
- rubygems_version: 2.4.5
172
+ rubygems_version: 2.4.6
173
173
  signing_key:
174
174
  specification_version: 4
175
175
  summary: ''