magellan-rails 0.2.3 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
 - data/ChangeLog.md +7 -0
 - data/Gemfile +0 -3
 - data/LICENSE.txt +1 -1
 - data/README.md +20 -19
 - data/gems/magellan-publisher/LICENSE.txt +1 -1
 - data/gems/magellan-publisher/lib/magellan/publisher.rb +14 -4
 - data/gems/magellan-publisher/lib/magellan/publisher/version.rb +1 -1
 - data/gems/magellan-publisher/magellan-publisher.gemspec +2 -2
 - data/gems/magellan-publisher/spec/magellan/publisher_spec.rb +31 -8
 - data/lib/magellan/rails/request.rb +1 -1
 - data/lib/magellan/rails/version.rb +1 -1
 - data/lib/magellan/worker/config.rb +1 -0
 - data/lib/magellan/worker/core.rb +55 -27
 - data/magellan-rails.gemspec +2 -3
 - data/spec/magellan/worker/core_spec.rb +66 -89
 - metadata +6 -5
 
    
        checksums.yaml
    CHANGED
    
    | 
         @@ -1,7 +1,7 @@ 
     | 
|
| 
       1 
1 
     | 
    
         
             
            ---
         
     | 
| 
       2 
2 
     | 
    
         
             
            SHA1:
         
     | 
| 
       3 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       4 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 3 
     | 
    
         
            +
              metadata.gz: 231109b7dd8ed557f11184f6533773c31f062376
         
     | 
| 
      
 4 
     | 
    
         
            +
              data.tar.gz: d75401b143155636dca006515648a596d01d969e
         
     | 
| 
       5 
5 
     | 
    
         
             
            SHA512:
         
     | 
| 
       6 
     | 
    
         
            -
              metadata.gz:  
     | 
| 
       7 
     | 
    
         
            -
              data.tar.gz:  
     | 
| 
      
 6 
     | 
    
         
            +
              metadata.gz: ed19a72f0274ad5b5a1f8076ec2fcb3649fefba52d848d63305dd9bb426056df7a2ee7c3141246fe03279f8a89654fe0effac0df4fcdd89186d831a74a1caeaa
         
     | 
| 
      
 7 
     | 
    
         
            +
              data.tar.gz: 272bbefd6ff9ac58f4db4c550363c07fe74e14a7457e08107e27ec8bf8a3ba2353408df93757727bb2cbef9ad9e606b8fdbc7bedcfaf87c371bc2db7f8a595e3
         
     | 
    
        data/ChangeLog.md
    ADDED
    
    
    
        data/Gemfile
    CHANGED
    
    
    
        data/LICENSE.txt
    CHANGED
    
    
    
        data/README.md
    CHANGED
    
    | 
         @@ -1,29 +1,30 @@ 
     | 
|
| 
       1 
     | 
    
         
            -
            #  
     | 
| 
      
 1 
     | 
    
         
            +
            # magellan-rails
         
     | 
| 
       2 
2 
     | 
    
         | 
| 
       3 
     | 
    
         
            -
             
     | 
| 
      
 3 
     | 
    
         
            +
            MAGELLAN adapter for Ruby on Rails framework.
         
     | 
| 
       4 
4 
     | 
    
         | 
| 
       5 
     | 
    
         
            -
             
     | 
| 
      
 5 
     | 
    
         
            +
            MAGELLAN: https://www.magellanic-clouds.com/
         
     | 
| 
       6 
6 
     | 
    
         | 
| 
       7 
     | 
    
         
            -
             
     | 
| 
       8 
     | 
    
         
            -
             
     | 
| 
       9 
     | 
    
         
            -
                gem 'magellan-rails'
         
     | 
| 
       10 
     | 
    
         
            -
             
     | 
| 
       11 
     | 
    
         
            -
            And then execute:
         
     | 
| 
      
 7 
     | 
    
         
            +
            ## Usage
         
     | 
| 
       12 
8 
     | 
    
         | 
| 
       13 
     | 
    
         
            -
             
     | 
| 
      
 9 
     | 
    
         
            +
            Add the following line into your Gemfile and execute `bundle install`.
         
     | 
| 
       14 
10 
     | 
    
         | 
| 
       15 
     | 
    
         
            -
             
     | 
| 
      
 11 
     | 
    
         
            +
            ```
         
     | 
| 
      
 12 
     | 
    
         
            +
            gem "magellan-rails"
         
     | 
| 
      
 13 
     | 
    
         
            +
            ```
         
     | 
| 
       16 
14 
     | 
    
         | 
| 
       17 
     | 
    
         
            -
             
     | 
| 
      
 15 
     | 
    
         
            +
            And add the following line into `config/application.rb` in your Rails application.
         
     | 
| 
       18 
16 
     | 
    
         | 
| 
       19 
     | 
    
         
            -
             
     | 
| 
      
 17 
     | 
    
         
            +
            ```
         
     | 
| 
      
 18 
     | 
    
         
            +
            require "magellan/rails"
         
     | 
| 
      
 19 
     | 
    
         
            +
            ```
         
     | 
| 
       20 
20 
     | 
    
         | 
| 
       21 
     | 
    
         
            -
             
     | 
| 
      
 21 
     | 
    
         
            +
            See Tutorial for more details.
         
     | 
| 
      
 22 
     | 
    
         
            +
            http://devcenter.magellanic-clouds.com/getting-started/ch05-03.html (Japanese only)
         
     | 
| 
       22 
23 
     | 
    
         | 
| 
       23 
     | 
    
         
            -
            ##  
     | 
| 
      
 24 
     | 
    
         
            +
            ## Environment Variables
         
     | 
| 
       24 
25 
     | 
    
         | 
| 
       25 
     | 
    
         
            -
             
     | 
| 
       26 
     | 
    
         
            -
             
     | 
| 
       27 
     | 
    
         
            -
             
     | 
| 
       28 
     | 
    
         
            -
             
     | 
| 
       29 
     | 
    
         
            -
             
     | 
| 
      
 26 
     | 
    
         
            +
            | Environment Variable                  | Default | Description |
         
     | 
| 
      
 27 
     | 
    
         
            +
            |---------------------------------------|---------|-------------|
         
     | 
| 
      
 28 
     | 
    
         
            +
            | MAGELLAN_HTTP_WORKER                  |    1    | 1/true/yes/on for load HTTP worker models. 0/false/no/off for suppress loading models for HTTP worker |
         
     | 
| 
      
 29 
     | 
    
         
            +
            | MAGELLAN_SUBSCRIBER_WORKER            |    1    | 1/true/yes/on for load Subscriber(MQTT) worker models. 0/false/no/off for suppress loading models for Subscriber(MQTT) worker |
         
     | 
| 
      
 30 
     | 
    
         
            +
            | MAGELLAN_RAILS_AMQP_RECONNECT_TIMEOUT |   300   | How long wait for AMQP reconnect in seconds. |
         
     | 
| 
         @@ -2,8 +2,10 @@ 
     | 
|
| 
       2 
2 
     | 
    
         | 
| 
       3 
3 
     | 
    
         
             
            module Magellan
         
     | 
| 
       4 
4 
     | 
    
         
             
              class Publisher
         
     | 
| 
      
 5 
     | 
    
         
            +
                class MessageTooLong < StandardError; end
         
     | 
| 
      
 6 
     | 
    
         
            +
             
     | 
| 
       5 
7 
     | 
    
         
             
                def initialize(host: nil, port: nil, vhost: nil, user: nil, pass: nil, timeout: nil)
         
     | 
| 
       6 
     | 
    
         
            -
                  #  
     | 
| 
      
 8 
     | 
    
         
            +
                  # connection settings for AMQP
         
     | 
| 
       7 
9 
     | 
    
         
             
                  connection_settings = {
         
     | 
| 
       8 
10 
     | 
    
         
             
                    host:    load_env_as_default(host,    ['MAGELLAN_PUBLISH_AMQP_ADDR'],    :string),
         
     | 
| 
       9 
11 
     | 
    
         
             
                    port:    load_env_as_default(port,    ['MAGELLAN_PUBLISH_AMQP_PORT'],    :integer),
         
     | 
| 
         @@ -19,10 +21,15 @@ module Magellan 
     | 
|
| 
       19 
21 
     | 
    
         | 
| 
       20 
22 
     | 
    
         
             
                  exchange_name  = ENV["MAGELLAN_PUBLISH_EXCHANGE"] || "magellan_publish"
         
     | 
| 
       21 
23 
     | 
    
         | 
| 
       22 
     | 
    
         
            -
                  # no_declare 
     | 
| 
       23 
     | 
    
         
            -
                  # Acess Contorolにひっかかりエラーとなります
         
     | 
| 
       24 
     | 
    
         
            -
                  # exchangeはmagellan-conductorによって作成済みの想定です
         
     | 
| 
      
 24 
     | 
    
         
            +
                  # here :no_declare options should be true to get rid of Access Control Error.
         
     | 
| 
       25 
25 
     | 
    
         
             
                  @exchange = @channel.exchange(exchange_name, no_declare: true)
         
     | 
| 
      
 26 
     | 
    
         
            +
             
     | 
| 
      
 27 
     | 
    
         
            +
                  # publish message size limit
         
     | 
| 
      
 28 
     | 
    
         
            +
                  @message_size_limit = load_env_as_default(nil, ["MAGELLAN_PUBLISH_MESSAGE_SIZE_LIMIT"], :integer) || (256 * 1024 * 1024)
         
     | 
| 
      
 29 
     | 
    
         
            +
                  # message size limit should be treated equally with MQTT message.
         
     | 
| 
      
 30 
     | 
    
         
            +
                  # substruct MQTT's topic length (2 bytes)
         
     | 
| 
      
 31 
     | 
    
         
            +
                  # currently magellan-publisher can publish message only in QoS=0 mode. so packet identifier record is not included in a packet.
         
     | 
| 
      
 32 
     | 
    
         
            +
                  @message_size_limit -= 2
         
     | 
| 
       26 
33 
     | 
    
         
             
                end
         
     | 
| 
       27 
34 
     | 
    
         | 
| 
       28 
35 
     | 
    
         
             
                def convert_topic(mqtt_topic)
         
     | 
| 
         @@ -31,6 +38,9 @@ module Magellan 
     | 
|
| 
       31 
38 
     | 
    
         
             
                private :convert_topic
         
     | 
| 
       32 
39 
     | 
    
         | 
| 
       33 
40 
     | 
    
         
             
                def publish(topic, body)
         
     | 
| 
      
 41 
     | 
    
         
            +
                  if topic.bytesize + body.bytesize > @message_size_limit
         
     | 
| 
      
 42 
     | 
    
         
            +
                    raise MessageTooLong, "publishing topic(#{topic.bytesize} bytes) and payload(#{body.bytesize} bytes) exceed message size limitation(#{@message_size_limit} bytes)."
         
     | 
| 
      
 43 
     | 
    
         
            +
                  end
         
     | 
| 
       34 
44 
     | 
    
         
             
                  @exchange.publish(body, routing_key: convert_topic(topic))
         
     | 
| 
       35 
45 
     | 
    
         
             
                end
         
     | 
| 
       36 
46 
     | 
    
         | 
| 
         @@ -6,8 +6,8 @@ require 'magellan/publisher/version' 
     | 
|
| 
       6 
6 
     | 
    
         
             
            Gem::Specification.new do |spec|
         
     | 
| 
       7 
7 
     | 
    
         
             
              spec.name          = "magellan-publisher"
         
     | 
| 
       8 
8 
     | 
    
         
             
              spec.version       = Magellan::Publisher::VERSION
         
     | 
| 
       9 
     | 
    
         
            -
              spec.authors       = [" 
     | 
| 
       10 
     | 
    
         
            -
              spec.email         = [" 
     | 
| 
      
 9 
     | 
    
         
            +
              spec.authors       = ["Groovenauts, Inc."]
         
     | 
| 
      
 10 
     | 
    
         
            +
              spec.email         = ["tech@groovenauts.jp"]
         
     | 
| 
       11 
11 
     | 
    
         
             
              spec.summary       = %q{}
         
     | 
| 
       12 
12 
     | 
    
         
             
              spec.description   = %q{}
         
     | 
| 
       13 
13 
     | 
    
         
             
              spec.homepage      = ""
         
     | 
| 
         @@ -16,22 +16,45 @@ describe Magellan::Publisher do 
     | 
|
| 
       16 
16 
     | 
    
         
             
                  @bunny    = BunnyMock.new
         
     | 
| 
       17 
17 
     | 
    
         
             
                  channel = @bunny.create_channel
         
     | 
| 
       18 
18 
     | 
    
         
             
                  @exchange = @bunny.exchange('test_exchange', type: :direct, durable: false, auto_delete: false)
         
     | 
| 
       19 
     | 
    
         
            -
                  expect(@exchange).to receive(:publish).with(@payload, routing_key: @rabbitmq_topic)
         
     | 
| 
       20 
19 
     | 
    
         | 
| 
       21 
20 
     | 
    
         
             
                  allow(Bunny  ).to receive(:new).and_return(@bunny)
         
     | 
| 
       22 
21 
     | 
    
         
             
                  allow(@bunny  ).to receive(:create_channel).and_return(channel)
         
     | 
| 
       23 
22 
     | 
    
         
             
                  allow(channel).to receive(:exchange).with('test_exchange', no_declare: true).and_return(@exchange)
         
     | 
| 
       24 
23 
     | 
    
         | 
| 
       25 
24 
     | 
    
         
             
                  ENV["MAGELLAN_PUBLISH_EXCHANGE"] = "test_exchange"
         
     | 
| 
       26 
     | 
    
         
            -
                  @publisher = Magellan::Publisher.new(host: "127.0.0.1",
         
     | 
| 
       27 
     | 
    
         
            -
                                                       port: 5672,
         
     | 
| 
       28 
     | 
    
         
            -
                                                       vhost: "/customer1.sample_project",
         
     | 
| 
       29 
     | 
    
         
            -
                                                       user: "customer1.sample_project",
         
     | 
| 
       30 
     | 
    
         
            -
                                                       pass: "pasw1")
         
     | 
| 
       31 
25 
     | 
    
         
             
                end
         
     | 
| 
       32 
26 
     | 
    
         | 
| 
       33 
     | 
    
         
            -
                 
     | 
| 
       34 
     | 
    
         
            -
                   
     | 
| 
      
 27 
     | 
    
         
            +
                context "normally" do
         
     | 
| 
      
 28 
     | 
    
         
            +
                  before do
         
     | 
| 
      
 29 
     | 
    
         
            +
                    expect(@exchange).to receive(:publish).with(@payload, routing_key: @rabbitmq_topic)
         
     | 
| 
      
 30 
     | 
    
         
            +
                    @publisher = Magellan::Publisher.new(host: "127.0.0.1",
         
     | 
| 
      
 31 
     | 
    
         
            +
                                                         port: 5672,
         
     | 
| 
      
 32 
     | 
    
         
            +
                                                         vhost: "/customer1.sample_project",
         
     | 
| 
      
 33 
     | 
    
         
            +
                                                         user: "customer1.sample_project",
         
     | 
| 
      
 34 
     | 
    
         
            +
                                                         pass: "pasw1")
         
     | 
| 
      
 35 
     | 
    
         
            +
                  end
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
                  it do
         
     | 
| 
      
 38 
     | 
    
         
            +
                    @publisher.publish(@topic, @payload)
         
     | 
| 
      
 39 
     | 
    
         
            +
                  end
         
     | 
| 
      
 40 
     | 
    
         
            +
                end
         
     | 
| 
      
 41 
     | 
    
         
            +
             
     | 
| 
      
 42 
     | 
    
         
            +
                context "message size limit exceed" do
         
     | 
| 
      
 43 
     | 
    
         
            +
                  before do
         
     | 
| 
      
 44 
     | 
    
         
            +
                    ENV["MAGELLAN_PUBLISH_MESSAGE_SIZE_LIMIT"] = (@topic.size + @payload.size + 1).to_s
         
     | 
| 
      
 45 
     | 
    
         
            +
                    @publisher = Magellan::Publisher.new(host: "127.0.0.1",
         
     | 
| 
      
 46 
     | 
    
         
            +
                                                         port: 5672,
         
     | 
| 
      
 47 
     | 
    
         
            +
                                                         vhost: "/customer1.sample_project",
         
     | 
| 
      
 48 
     | 
    
         
            +
                                                         user: "customer1.sample_project",
         
     | 
| 
      
 49 
     | 
    
         
            +
                                                         pass: "pasw1")
         
     | 
| 
      
 50 
     | 
    
         
            +
                  end
         
     | 
| 
      
 51 
     | 
    
         
            +
                  after do
         
     | 
| 
      
 52 
     | 
    
         
            +
                    ENV["MAGELLAN_PUBLISH_MESSAGE_SIZE_LIMIT"] = nil
         
     | 
| 
      
 53 
     | 
    
         
            +
                  end
         
     | 
| 
      
 54 
     | 
    
         
            +
             
     | 
| 
      
 55 
     | 
    
         
            +
                  it do
         
     | 
| 
      
 56 
     | 
    
         
            +
                    expect { @publisher.publish(@topic, @payload) }.to raise_error(Magellan::Publisher::MessageTooLong)
         
     | 
| 
      
 57 
     | 
    
         
            +
                  end
         
     | 
| 
       35 
58 
     | 
    
         
             
                end
         
     | 
| 
       36 
59 
     | 
    
         
             
              end
         
     | 
| 
       37 
60 
     | 
    
         | 
| 
         @@ -41,6 +41,7 @@ module Magellan::Worker::Config 
     | 
|
| 
       41 
41 
     | 
    
         
             
                  config[:publish_user]      = ENV["MAGELLAN_PUBLISH_AMQP_USER"]
         
     | 
| 
       42 
42 
     | 
    
         
             
                  config[:publish_password]  = ENV["MAGELLAN_PUBLISH_AMQP_PASS"]
         
     | 
| 
       43 
43 
     | 
    
         
             
                  config[:publish_exchange]  = ENV["MAGELLAN_PUBLISH_EXCHANGE"]
         
     | 
| 
      
 44 
     | 
    
         
            +
                  config[:amqp_reconnect_timeout] = (ENV["MAGELLAN_RAILS_AMQP_RECONNECT_TIMEOUT"] || 300).to_i
         
     | 
| 
       44 
45 
     | 
    
         
             
                  config
         
     | 
| 
       45 
46 
     | 
    
         
             
                end
         
     | 
| 
       46 
47 
     | 
    
         
             
              end
         
     | 
    
        data/lib/magellan/worker/core.rb
    CHANGED
    
    | 
         @@ -24,11 +24,21 @@ class Magellan::Worker::Core 
     | 
|
| 
       24 
24 
     | 
    
         
             
                  vhost:   @config[:vhost],
         
     | 
| 
       25 
25 
     | 
    
         
             
                  user:    @config[:rabbitmq_user],
         
     | 
| 
       26 
26 
     | 
    
         
             
                  pass:    @config[:rabbitmq_password],
         
     | 
| 
       27 
     | 
    
         
            -
                  timeout: 0.3
         
     | 
| 
      
 27 
     | 
    
         
            +
                  timeout: 0.3,
         
     | 
| 
      
 28 
     | 
    
         
            +
                  heartbeat_interval: 60,
         
     | 
| 
       28 
29 
     | 
    
         
             
                }
         
     | 
| 
       29 
30 
     | 
    
         | 
| 
       30 
31 
     | 
    
         
             
                @conn = Bunny.new(connection_settings)
         
     | 
| 
       31 
32 
     | 
    
         
             
                @conn.start
         
     | 
| 
      
 33 
     | 
    
         
            +
             
     | 
| 
      
 34 
     | 
    
         
            +
                open_channel
         
     | 
| 
      
 35 
     | 
    
         
            +
             
     | 
| 
      
 36 
     | 
    
         
            +
                @shutdown = false
         
     | 
| 
      
 37 
     | 
    
         
            +
             
     | 
| 
      
 38 
     | 
    
         
            +
                self
         
     | 
| 
      
 39 
     | 
    
         
            +
              end
         
     | 
| 
      
 40 
     | 
    
         
            +
             
     | 
| 
      
 41 
     | 
    
         
            +
              def open_channel
         
     | 
| 
       32 
42 
     | 
    
         
             
                @channel  = @conn.create_channel
         
     | 
| 
       33 
43 
     | 
    
         | 
| 
       34 
44 
     | 
    
         
             
                queue_name     = @config[:request_queue]
         
     | 
| 
         @@ -37,14 +47,10 @@ class Magellan::Worker::Core 
     | 
|
| 
       37 
47 
     | 
    
         
             
                # no_declareを設定しない場合、キューやエクスチェンジに対してdeclareを実行してしまい、
         
     | 
| 
       38 
48 
     | 
    
         
             
                # Acess Contorolにひっかかりエラーとなります
         
     | 
| 
       39 
49 
     | 
    
         
             
                # queueとexchange及びbindはmagellan-conductorによって作成済みの想定です
         
     | 
| 
       40 
     | 
    
         
            -
                @queue    = @channel.queue(queue_name, no_declare: true)
         
     | 
| 
       41 
     | 
    
         
            -
                @exchange = @channel.exchange(exchange_name, no_declare: true)
         
     | 
| 
      
 50 
     | 
    
         
            +
                @queue    = @channel.queue(queue_name, no_declare: true, durable: true)
         
     | 
| 
      
 51 
     | 
    
         
            +
                @exchange = @channel.exchange(exchange_name, no_declare: true, durable: true)
         
     | 
| 
       42 
52 
     | 
    
         | 
| 
       43 
53 
     | 
    
         
             
                @executor = Magellan::Worker::Executor.new(@exchange)
         
     | 
| 
       44 
     | 
    
         
            -
             
     | 
| 
       45 
     | 
    
         
            -
                @shutdown = false
         
     | 
| 
       46 
     | 
    
         
            -
             
     | 
| 
       47 
     | 
    
         
            -
                self
         
     | 
| 
       48 
54 
     | 
    
         
             
              end
         
     | 
| 
       49 
55 
     | 
    
         | 
| 
       50 
56 
     | 
    
         
             
              def shutdown
         
     | 
| 
         @@ -52,6 +58,20 @@ class Magellan::Worker::Core 
     | 
|
| 
       52 
58 
     | 
    
         
             
                @shutdown = true
         
     | 
| 
       53 
59 
     | 
    
         
             
              end
         
     | 
| 
       54 
60 
     | 
    
         | 
| 
      
 61 
     | 
    
         
            +
              def wait_reconnect
         
     | 
| 
      
 62 
     | 
    
         
            +
                limit = Time.now + @config[:amqp_reconnect_timeout]
         
     | 
| 
      
 63 
     | 
    
         
            +
                while Time.now <= limit and not(@shutdown)
         
     | 
| 
      
 64 
     | 
    
         
            +
                  sleep 1.0
         
     | 
| 
      
 65 
     | 
    
         
            +
                  if @channel.connection.status == :open
         
     | 
| 
      
 66 
     | 
    
         
            +
                    @channel.close rescue nil
         
     | 
| 
      
 67 
     | 
    
         
            +
                    open_channel
         
     | 
| 
      
 68 
     | 
    
         
            +
                    Magellan.logger.info("== AMQP connection recovered ==")
         
     | 
| 
      
 69 
     | 
    
         
            +
                    return true
         
     | 
| 
      
 70 
     | 
    
         
            +
                  end
         
     | 
| 
      
 71 
     | 
    
         
            +
                end
         
     | 
| 
      
 72 
     | 
    
         
            +
                return false
         
     | 
| 
      
 73 
     | 
    
         
            +
              end
         
     | 
| 
      
 74 
     | 
    
         
            +
             
     | 
| 
       55 
75 
     | 
    
         
             
              def run
         
     | 
| 
       56 
76 
     | 
    
         
             
                # reset for re-run
         
     | 
| 
       57 
77 
     | 
    
         
             
                @shutdown = false
         
     | 
| 
         @@ -62,27 +82,35 @@ class Magellan::Worker::Core 
     | 
|
| 
       62 
82 
     | 
    
         
             
                end
         
     | 
| 
       63 
83 
     | 
    
         | 
| 
       64 
84 
     | 
    
         
             
                Magellan.logger.info("====== Magellan Worker start ======")
         
     | 
| 
       65 
     | 
    
         
            -
                @ 
     | 
| 
       66 
     | 
    
         
            -
                   
     | 
| 
       67 
     | 
    
         
            -
             
     | 
| 
       68 
     | 
    
         
            -
             
     | 
| 
       69 
     | 
    
         
            -
             
     | 
| 
       70 
     | 
    
         
            -
             
     | 
| 
       71 
     | 
    
         
            -
             
     | 
| 
       72 
     | 
    
         
            -
             
     | 
| 
       73 
     | 
    
         
            -
             
     | 
| 
       74 
     | 
    
         
            -
             
     | 
| 
       75 
     | 
    
         
            -
             
     | 
| 
       76 
     | 
    
         
            -
             
     | 
| 
       77 
     | 
    
         
            -
             
     | 
| 
       78 
     | 
    
         
            -
             
     | 
| 
       79 
     | 
    
         
            -
                     
     | 
| 
       80 
     | 
    
         
            -
             
     | 
| 
       81 
     | 
    
         
            -
             
     | 
| 
       82 
     | 
    
         
            -
                     
     | 
| 
      
 85 
     | 
    
         
            +
                until @shutdown
         
     | 
| 
      
 86 
     | 
    
         
            +
                  @queue.subscribe(block: true, manual_ack: true) do |delivery_info, properties, payload|
         
     | 
| 
      
 87 
     | 
    
         
            +
                    reply_to       = properties.reply_to        # ワーカー実行結果返却時のルーティングキー
         
     | 
| 
      
 88 
     | 
    
         
            +
                    correlation_id = properties.correlation_id  # ワーカー実行結果返却時にどのリクエストに対応するメッセージか判別するための識別子
         
     | 
| 
      
 89 
     | 
    
         
            +
                    delivery_tag   = delivery_info.delivery_tag # ackを返却時に使用
         
     | 
| 
      
 90 
     | 
    
         
            +
             
     | 
| 
      
 91 
     | 
    
         
            +
                    # ワーカーロジック実行中に落ちたとしてもRabbitMQから再送させないために
         
     | 
| 
      
 92 
     | 
    
         
            +
                    # メッセージを取得した直後にackを返します
         
     | 
| 
      
 93 
     | 
    
         
            +
                    # 第1引数: ackを返す対象のメッセージを指定
         
     | 
| 
      
 94 
     | 
    
         
            +
                    # 第2引数: ackを返す対象以前のメッセージもackを返すか
         
     | 
| 
      
 95 
     | 
    
         
            +
                    #  true:  指定したメッセージ以前に受信したメッセージ全てが対象
         
     | 
| 
      
 96 
     | 
    
         
            +
                    #  false: 指定したメッセージのみが対象
         
     | 
| 
      
 97 
     | 
    
         
            +
                    @channel.basic_ack(delivery_tag, false)
         
     | 
| 
      
 98 
     | 
    
         
            +
             
     | 
| 
      
 99 
     | 
    
         
            +
                    begin
         
     | 
| 
      
 100 
     | 
    
         
            +
                      request_message = parse_body(payload)
         
     | 
| 
      
 101 
     | 
    
         
            +
                      @executor.execute(reply_to, correlation_id, delivery_tag, request_message)
         
     | 
| 
      
 102 
     | 
    
         
            +
                    rescue
         
     | 
| 
      
 103 
     | 
    
         
            +
                      Magellan.logger.error("Magellan Worker request execution error: #{$!}\n" + $@.join("\n"))
         
     | 
| 
      
 104 
     | 
    
         
            +
                    end
         
     | 
| 
      
 105 
     | 
    
         
            +
                    if @shutdown
         
     | 
| 
      
 106 
     | 
    
         
            +
                      delivery_info.consumer.cancel
         
     | 
| 
      
 107 
     | 
    
         
            +
                    end
         
     | 
| 
       83 
108 
     | 
    
         
             
                  end
         
     | 
| 
       84 
     | 
    
         
            -
                   
     | 
| 
       85 
     | 
    
         
            -
             
     | 
| 
      
 109 
     | 
    
         
            +
                  # AMQPの接続が切れると Queue#subscribe から処理が帰るので再接続を待つ
         
     | 
| 
      
 110 
     | 
    
         
            +
                  break if @shutdown
         
     | 
| 
      
 111 
     | 
    
         
            +
                  unless wait_reconnect
         
     | 
| 
      
 112 
     | 
    
         
            +
                    Magellan.logger.info("magellan-rails: AMQP reconnect timeout")
         
     | 
| 
      
 113 
     | 
    
         
            +
                    break
         
     | 
| 
       86 
114 
     | 
    
         
             
                  end
         
     | 
| 
       87 
115 
     | 
    
         
             
                end
         
     | 
| 
       88 
116 
     | 
    
         
             
                Magellan.logger.info("====== Magellan Worker finished ======")
         
     | 
    
        data/magellan-rails.gemspec
    CHANGED
    
    | 
         @@ -6,8 +6,8 @@ require 'magellan/rails/version' 
     | 
|
| 
       6 
6 
     | 
    
         
             
            Gem::Specification.new do |spec|
         
     | 
| 
       7 
7 
     | 
    
         
             
              spec.name          = "magellan-rails"
         
     | 
| 
       8 
8 
     | 
    
         
             
              spec.version       = Magellan::Rails::VERSION
         
     | 
| 
       9 
     | 
    
         
            -
              spec.authors       = [" 
     | 
| 
       10 
     | 
    
         
            -
              spec.email         = [" 
     | 
| 
      
 9 
     | 
    
         
            +
              spec.authors       = ["Groovenauts, Inc."]
         
     | 
| 
      
 10 
     | 
    
         
            +
              spec.email         = ["tech@groovenauts.jp"]
         
     | 
| 
       11 
11 
     | 
    
         
             
              spec.summary       = %q{}
         
     | 
| 
       12 
12 
     | 
    
         
             
              spec.description   = %q{}
         
     | 
| 
       13 
13 
     | 
    
         
             
              spec.homepage      = ""
         
     | 
| 
         @@ -25,5 +25,4 @@ Gem::Specification.new do |spec| 
     | 
|
| 
       25 
25 
     | 
    
         | 
| 
       26 
26 
     | 
    
         
             
              spec.add_development_dependency "bundler", "~> 1.6"
         
     | 
| 
       27 
27 
     | 
    
         
             
              spec.add_development_dependency "rspec"
         
     | 
| 
       28 
     | 
    
         
            -
              # spec.add_development_dependency "bunny_mock"
         
     | 
| 
       29 
28 
     | 
    
         
             
            end
         
     | 
| 
         @@ -2,13 +2,46 @@ 
     | 
|
| 
       2 
2 
     | 
    
         | 
| 
       3 
3 
     | 
    
         
             
            require "spec_helper"
         
     | 
| 
       4 
4 
     | 
    
         
             
            require 'bunny'
         
     | 
| 
       5 
     | 
    
         
            -
            require 'bunny_mock'
         
     | 
| 
       6 
5 
     | 
    
         
             
            require 'json'
         
     | 
| 
       7 
6 
     | 
    
         
             
            require 'msgpack'
         
     | 
| 
       8 
7 
     | 
    
         | 
| 
       9 
8 
     | 
    
         
             
            describe Magellan::Worker::Core do
         
     | 
| 
       10 
9 
     | 
    
         | 
| 
       11 
10 
     | 
    
         
             
              describe "#run" do
         
     | 
| 
      
 11 
     | 
    
         
            +
                before do
         
     | 
| 
      
 12 
     | 
    
         
            +
                  bunny    = double(:bunny)
         
     | 
| 
      
 13 
     | 
    
         
            +
                  channel = double(:channel)
         
     | 
| 
      
 14 
     | 
    
         
            +
                  exchange = double(:exchange, name: 'test_exchange', type: :direct, durable: false, auto_delete: false)
         
     | 
| 
      
 15 
     | 
    
         
            +
                  @queue    = double(:queue, name: "consumer1.sample_project.1.0.0.rails")
         
     | 
| 
      
 16 
     | 
    
         
            +
                  work_pool = double "work_pool"
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
                  allow(Bunny  ).to receive(:new).and_return(bunny)
         
     | 
| 
      
 19 
     | 
    
         
            +
                  allow(bunny  ).to receive(:start)
         
     | 
| 
      
 20 
     | 
    
         
            +
                  allow(bunny  ).to receive(:create_channel).and_return(channel)
         
     | 
| 
      
 21 
     | 
    
         
            +
                  allow(channel).to receive(:queue).with('customer1.sample_project.1.0.0.rails', no_declare: true, durable: true).and_return(@queue)
         
     | 
| 
      
 22 
     | 
    
         
            +
                  allow(channel).to receive(:exchange).with("customer1.sample_project.reply", no_declare: true, durable: true).and_return(exchange)
         
     | 
| 
      
 23 
     | 
    
         
            +
                  allow(channel).to receive(:basic_ack).and_return(@queue)
         
     | 
| 
      
 24 
     | 
    
         
            +
                  allow(channel).to receive(:work_pool).and_return(work_pool)
         
     | 
| 
      
 25 
     | 
    
         
            +
                  allow(channel).to receive(:connection).and_return(double(:connection, status: :closed))
         
     | 
| 
      
 26 
     | 
    
         
            +
                  allow(channel).to receive(:open)
         
     | 
| 
      
 27 
     | 
    
         
            +
                  allow(work_pool).to receive(:shutdown)
         
     | 
| 
      
 28 
     | 
    
         
            +
             
     | 
| 
      
 29 
     | 
    
         
            +
             
     | 
| 
      
 30 
     | 
    
         
            +
                  config = {}
         
     | 
| 
      
 31 
     | 
    
         
            +
                  config[:host]              = '127.0.0.1'
         
     | 
| 
      
 32 
     | 
    
         
            +
                  config[:port]              = '5672'
         
     | 
| 
      
 33 
     | 
    
         
            +
                  config[:vhost]             = '/customer1.sample_project'
         
     | 
| 
      
 34 
     | 
    
         
            +
                  config[:rabbitmq_user]     = 'customer1.sample_project'
         
     | 
| 
      
 35 
     | 
    
         
            +
                  config[:request_queue]     = 'customer1.sample_project.1.0.0.rails'
         
     | 
| 
      
 36 
     | 
    
         
            +
                  config[:response_exchange] = 'customer1.sample_project.reply'
         
     | 
| 
      
 37 
     | 
    
         
            +
                  config[:rabbitmq_password] = 'pswd1'
         
     | 
| 
      
 38 
     | 
    
         
            +
                  config[:amqp_reconnect_timeout] = 1
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
      
 40 
     | 
    
         
            +
                  allow(Magellan::Worker::Config).to receive(:load_config).and_return(config)
         
     | 
| 
      
 41 
     | 
    
         
            +
             
     | 
| 
      
 42 
     | 
    
         
            +
                  @executor = double('executor')
         
     | 
| 
      
 43 
     | 
    
         
            +
                  allow(Magellan::Worker::Executor).to receive(:new).and_return(@executor)
         
     | 
| 
      
 44 
     | 
    
         
            +
                end
         
     | 
| 
       12 
45 
     | 
    
         | 
| 
       13 
46 
     | 
    
         
             
                context "set all env" do
         
     | 
| 
       14 
47 
     | 
    
         
             
                  before do
         
     | 
| 
         @@ -28,43 +61,27 @@ describe Magellan::Worker::Core do 
     | 
|
| 
       28 
61 
     | 
    
         
             
                        'reply_ttl' => 1000
         
     | 
| 
       29 
62 
     | 
    
         
             
                      }
         
     | 
| 
       30 
63 
     | 
    
         
             
                    }
         
     | 
| 
       31 
     | 
    
         
            -
             
     | 
| 
       32 
     | 
    
         
            -
                    bunny    = BunnyMock.new
         
     | 
| 
       33 
     | 
    
         
            -
                    channel = bunny.create_channel
         
     | 
| 
       34 
     | 
    
         
            -
                    exchange = bunny.exchange('test_exchange', type: :direct, durable: false, auto_delete: false)
         
     | 
| 
       35 
     | 
    
         
            -
                    queue    = channel.queue("consumer1.sample_project.1.0.0.rails")
         
     | 
| 
       36 
     | 
    
         
            -
                    queue.bind(exchange)
         
     | 
| 
       37 
     | 
    
         
            -
                    exchange.publish(@request_message.to_json, routing_key: "1.0.0.rails", reply_to: 'reply_test', correlation_id: "correlation_id_sample")
         
     | 
| 
       38 
     | 
    
         
            -
                    @work_pool = double "work_pool"
         
     | 
| 
       39 
     | 
    
         
            -
             
     | 
| 
       40 
     | 
    
         
            -
                    allow(Bunny  ).to receive(:new).and_return(bunny)
         
     | 
| 
       41 
     | 
    
         
            -
                    allow(bunny  ).to receive(:create_channel).and_return(channel)
         
     | 
| 
       42 
     | 
    
         
            -
                    allow(channel).to receive(:queue).with('customer1.sample_project.1.0.0.rails', no_declare: true).and_return(queue)
         
     | 
| 
       43 
     | 
    
         
            -
                    allow(channel).to receive(:basic_ack).and_return(queue)
         
     | 
| 
       44 
     | 
    
         
            -
                    allow(channel).to receive(:work_pool).and_return(@work_pool)
         
     | 
| 
       45 
     | 
    
         
            -
             
     | 
| 
       46 
     | 
    
         
            -
                    config = {}
         
     | 
| 
       47 
     | 
    
         
            -
                    config[:host]              = '127.0.0.1'
         
     | 
| 
       48 
     | 
    
         
            -
                    config[:port]              = '5672'
         
     | 
| 
       49 
     | 
    
         
            -
                    config[:vhost]             = '/customer1.sample_project'
         
     | 
| 
       50 
     | 
    
         
            -
                    config[:rabbitmq_user]     = 'customer1.sample_project'
         
     | 
| 
       51 
     | 
    
         
            -
                    config[:request_queue]     = 'customer1.sample_project.1.0.0.rails'
         
     | 
| 
       52 
     | 
    
         
            -
                    config[:response_exchange] = 'customer1.sample_project.reply'
         
     | 
| 
       53 
     | 
    
         
            -
                    config[:rabbitmq_password] = 'pswd1'
         
     | 
| 
       54 
     | 
    
         
            -
             
     | 
| 
       55 
     | 
    
         
            -
                    allow(Magellan::Worker::Config).to receive(:load_config).and_return(config)
         
     | 
| 
       56 
     | 
    
         
            -
             
     | 
| 
       57 
     | 
    
         
            -
                    @executor = double('executor')
         
     | 
| 
       58 
     | 
    
         
            -
                    allow(Magellan::Worker::Executor).to receive(:new).and_return(@executor)
         
     | 
| 
       59 
     | 
    
         
            -
                    allow(@executor).to receive(:execute).and_return(nil)
         
     | 
| 
       60 
64 
     | 
    
         
             
                  end
         
     | 
| 
       61 
65 
     | 
    
         | 
| 
       62 
66 
     | 
    
         
             
                  subject{ Magellan::Worker::Core.new.initialize! }
         
     | 
| 
       63 
67 
     | 
    
         
             
                  it do
         
     | 
| 
       64 
     | 
    
         
            -
                     
     | 
| 
       65 
     | 
    
         
            -
                     
     | 
| 
       66 
     | 
    
         
            -
                     
     | 
| 
       67 
     | 
    
         
            -
             
     | 
| 
      
 68 
     | 
    
         
            +
                    consumer = double(:consumer, cancel: nil)
         
     | 
| 
      
 69 
     | 
    
         
            +
                    delivery_info = double(:delivery_info, delivery_tag: "delivery_tag", consumer: consumer)
         
     | 
| 
      
 70 
     | 
    
         
            +
                    expect(@queue).to receive(:subscribe).with(block: true, manual_ack: true).and_yield(delivery_info,
         
     | 
| 
      
 71 
     | 
    
         
            +
                                                                                                        double(:properties, reply_to: "reply_test", correlation_id: "correlation_id_sample"),
         
     | 
| 
      
 72 
     | 
    
         
            +
                                                                                                        @request_message.to_json)
         
     | 
| 
      
 73 
     | 
    
         
            +
                    core = subject
         
     | 
| 
      
 74 
     | 
    
         
            +
                    # FIXME: RSpec3 mock obsolete and_return{ ... } feature and it seems no alternatives.
         
     | 
| 
      
 75 
     | 
    
         
            +
                    # Re-define `execute` method to emulate signal handling during the method execution.
         
     | 
| 
      
 76 
     | 
    
         
            +
                    @executor.singleton_class.module_eval do
         
     | 
| 
      
 77 
     | 
    
         
            +
                      define_method(:execute) do |*args|
         
     | 
| 
      
 78 
     | 
    
         
            +
                        core.shutdown
         
     | 
| 
      
 79 
     | 
    
         
            +
                        nil
         
     | 
| 
      
 80 
     | 
    
         
            +
                      end
         
     | 
| 
      
 81 
     | 
    
         
            +
                    end
         
     | 
| 
      
 82 
     | 
    
         
            +
                    expect(@executor).to receive(:execute).with("reply_test", "correlation_id_sample", "delivery_tag",  @request_message).once
         
     | 
| 
      
 83 
     | 
    
         
            +
                    core.run
         
     | 
| 
      
 84 
     | 
    
         
            +
                    expect(Magellan.logger).to be_a(Logger)
         
     | 
| 
       68 
85 
     | 
    
         
             
                  end
         
     | 
| 
       69 
86 
     | 
    
         
             
                end
         
     | 
| 
       70 
87 
     | 
    
         | 
| 
         @@ -75,7 +92,7 @@ describe Magellan::Worker::Core do 
     | 
|
| 
       75 
92 
     | 
    
         
             
                      'headers' => {
         
     | 
| 
       76 
93 
     | 
    
         
             
                        'Title'                => 'groovenauts-app',
         
     | 
| 
       77 
94 
     | 
    
         
             
                        'Interface-Version'    => '1.0.0',
         
     | 
| 
       78 
     | 
    
         
            -
                        'Title-Runtime-Version'=> ' 
     | 
| 
      
 95 
     | 
    
         
            +
                        'Title-Runtime-Version'=> '2.0.0',
         
     | 
| 
       79 
96 
     | 
    
         
             
                        'Reference-Id'         =>'192.168.1.110',
         
     | 
| 
       80 
97 
     | 
    
         
             
                        'Url'                  =>'http://magellan-clouds.com/worker/test',
         
     | 
| 
       81 
98 
     | 
    
         
             
                        'Oauth-Requester-Id'   =>'tarou',
         
     | 
| 
         @@ -86,66 +103,26 @@ describe Magellan::Worker::Core do 
     | 
|
| 
       86 
103 
     | 
    
         
             
                        'reply_ttl' => 1000
         
     | 
| 
       87 
104 
     | 
    
         
             
                      }
         
     | 
| 
       88 
105 
     | 
    
         
             
                    }
         
     | 
| 
       89 
     | 
    
         
            -
             
     | 
| 
       90 
     | 
    
         
            -
                    bunny    = BunnyMock.new
         
     | 
| 
       91 
     | 
    
         
            -
                    channel = bunny.create_channel
         
     | 
| 
       92 
     | 
    
         
            -
                    exchange = bunny.exchange('test_exchange', type: :direct, durable: false, auto_delete: false)
         
     | 
| 
       93 
     | 
    
         
            -
                    queue    = channel.queue("consumer1.sample_project.1.0.0.rails")
         
     | 
| 
       94 
     | 
    
         
            -
                    queue.bind(exchange)
         
     | 
| 
       95 
     | 
    
         
            -
                    exchange.publish(@request_message.to_msgpack, routing_key: "1.0.0.rails", reply_to: 'reply_test', correlation_id: "correlation_id_sample")
         
     | 
| 
       96 
     | 
    
         
            -
                    @work_pool = double "work_pool"
         
     | 
| 
       97 
     | 
    
         
            -
             
     | 
| 
       98 
     | 
    
         
            -
                    allow(Bunny  ).to receive(:new).and_return(bunny)
         
     | 
| 
       99 
     | 
    
         
            -
                    allow(bunny  ).to receive(:create_channel).and_return(channel)
         
     | 
| 
       100 
     | 
    
         
            -
                    allow(channel).to receive(:queue).with('customer1.sample_project.1.0.0.rails', no_declare: true).and_return(queue)
         
     | 
| 
       101 
     | 
    
         
            -
                    allow(channel).to receive(:basic_ack).and_return(queue)
         
     | 
| 
       102 
     | 
    
         
            -
                    allow(channel).to receive(:work_pool).and_return(@work_pool)
         
     | 
| 
       103 
     | 
    
         
            -
             
     | 
| 
       104 
     | 
    
         
            -
                    config = {}
         
     | 
| 
       105 
     | 
    
         
            -
                    config[:host]              = '127.0.0.1'
         
     | 
| 
       106 
     | 
    
         
            -
                    config[:port]              = '5672'
         
     | 
| 
       107 
     | 
    
         
            -
                    config[:vhost]             = '/customer1.sample_project'
         
     | 
| 
       108 
     | 
    
         
            -
                    config[:rabbitmq_user]     = 'customer1.sample_project'
         
     | 
| 
       109 
     | 
    
         
            -
                    config[:request_queue]     = 'customer1.sample_project.1.0.0.rails'
         
     | 
| 
       110 
     | 
    
         
            -
                    config[:response_exchange] = 'customer1.sample_project.reply'
         
     | 
| 
       111 
     | 
    
         
            -
                    config[:rabbitmq_password] = 'pswd1'
         
     | 
| 
       112 
     | 
    
         
            -
             
     | 
| 
       113 
     | 
    
         
            -
                    allow(Magellan::Worker::Config).to receive(:load_config).and_return(config)
         
     | 
| 
       114 
     | 
    
         
            -
             
     | 
| 
       115 
     | 
    
         
            -
                    @executor = double('executor')
         
     | 
| 
       116 
     | 
    
         
            -
                    allow(Magellan::Worker::Executor).to receive(:new).and_return(@executor)
         
     | 
| 
       117 
     | 
    
         
            -
                    allow(@executor).to receive(:execute).and_return(nil)
         
     | 
| 
       118 
106 
     | 
    
         
             
                  end
         
     | 
| 
       119 
107 
     | 
    
         | 
| 
       120 
108 
     | 
    
         
             
                  subject{ Magellan::Worker::Core.new.initialize! }
         
     | 
| 
       121 
109 
     | 
    
         
             
                  it do
         
     | 
| 
       122 
     | 
    
         
            -
                     
     | 
| 
       123 
     | 
    
         
            -
                     
     | 
| 
       124 
     | 
    
         
            -
                     
     | 
| 
       125 
     | 
    
         
            -
             
     | 
| 
       126 
     | 
    
         
            -
             
     | 
| 
       127 
     | 
    
         
            -
             
     | 
| 
       128 
     | 
    
         
            -
             
     | 
| 
       129 
     | 
    
         
            -
                     
     | 
| 
       130 
     | 
    
         
            -
             
     | 
| 
       131 
     | 
    
         
            -
                       
     | 
| 
       132 
     | 
    
         
            -
             
     | 
| 
       133 
     | 
    
         
            -
             
     | 
| 
       134 
     | 
    
         
            -
                    it do
         
     | 
| 
       135 
     | 
    
         
            -
                      expect(Magellan::Worker::Config).to receive(:load_config).once
         
     | 
| 
       136 
     | 
    
         
            -
                      expect(@work_pool).to receive(:shutdown).once
         
     | 
| 
       137 
     | 
    
         
            -
                      # store local variable to be referenced in module_eval block
         
     | 
| 
       138 
     | 
    
         
            -
                      core = subject()
         
     | 
| 
       139 
     | 
    
         
            -
                      # FIXME: RSpec3 mock obsolete and_return{ ... } feature and it seems no alternatives.
         
     | 
| 
       140 
     | 
    
         
            -
                      # Re-define `execute` method to emulate signal handling during the method execution.
         
     | 
| 
       141 
     | 
    
         
            -
                      @executor.singleton_class.module_eval do
         
     | 
| 
       142 
     | 
    
         
            -
                        define_method(:execute) do |*args|
         
     | 
| 
       143 
     | 
    
         
            -
                          core.shutdown
         
     | 
| 
       144 
     | 
    
         
            -
                          nil
         
     | 
| 
       145 
     | 
    
         
            -
                        end
         
     | 
| 
      
 110 
     | 
    
         
            +
                    consumer = double(:consumer, cancel: nil)
         
     | 
| 
      
 111 
     | 
    
         
            +
                    delivery_info = double(:delivery_info, delivery_tag: "delivery_tag", consumer: consumer)
         
     | 
| 
      
 112 
     | 
    
         
            +
                    expect(@queue).to receive(:subscribe).with(block: true, manual_ack: true).and_yield(delivery_info,
         
     | 
| 
      
 113 
     | 
    
         
            +
                                                                                                        double(:properties, reply_to: "reply_test", correlation_id: "correlation_id_sample"),
         
     | 
| 
      
 114 
     | 
    
         
            +
                                                                                                        @request_message.to_msgpack)
         
     | 
| 
      
 115 
     | 
    
         
            +
                    core = subject
         
     | 
| 
      
 116 
     | 
    
         
            +
                    # FIXME: RSpec3 mock obsolete and_return{ ... } feature and it seems no alternatives.
         
     | 
| 
      
 117 
     | 
    
         
            +
                    # Re-define `execute` method to emulate signal handling during the method execution.
         
     | 
| 
      
 118 
     | 
    
         
            +
                    @executor.singleton_class.module_eval do
         
     | 
| 
      
 119 
     | 
    
         
            +
                      define_method(:execute) do |*args|
         
     | 
| 
      
 120 
     | 
    
         
            +
                        core.shutdown
         
     | 
| 
      
 121 
     | 
    
         
            +
                        nil
         
     | 
| 
       146 
122 
     | 
    
         
             
                      end
         
     | 
| 
       147 
     | 
    
         
            -
                      subject.run
         
     | 
| 
       148 
123 
     | 
    
         
             
                    end
         
     | 
| 
      
 124 
     | 
    
         
            +
                    expect(@executor).to receive(:execute).with("reply_test", "correlation_id_sample", "delivery_tag",  @request_message).once
         
     | 
| 
      
 125 
     | 
    
         
            +
                    subject.run
         
     | 
| 
       149 
126 
     | 
    
         
             
                  end
         
     | 
| 
       150 
127 
     | 
    
         
             
                end
         
     | 
| 
       151 
128 
     | 
    
         
             
              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. 
     | 
| 
      
 4 
     | 
    
         
            +
              version: 0.2.4
         
     | 
| 
       5 
5 
     | 
    
         
             
            platform: ruby
         
     | 
| 
       6 
6 
     | 
    
         
             
            authors:
         
     | 
| 
       7 
     | 
    
         
            -
            -  
     | 
| 
      
 7 
     | 
    
         
            +
            - Groovenauts, Inc.
         
     | 
| 
       8 
8 
     | 
    
         
             
            autorequire: 
         
     | 
| 
       9 
9 
     | 
    
         
             
            bindir: bin
         
     | 
| 
       10 
10 
     | 
    
         
             
            cert_chain: []
         
     | 
| 
       11 
     | 
    
         
            -
            date: 2015- 
     | 
| 
      
 11 
     | 
    
         
            +
            date: 2015-09-11 00:00:00.000000000 Z
         
     | 
| 
       12 
12 
     | 
    
         
             
            dependencies:
         
     | 
| 
       13 
13 
     | 
    
         
             
            - !ruby/object:Gem::Dependency
         
     | 
| 
       14 
14 
     | 
    
         
             
              name: railties
         
     | 
| 
         @@ -96,7 +96,7 @@ dependencies: 
     | 
|
| 
       96 
96 
     | 
    
         
             
                    version: '0'
         
     | 
| 
       97 
97 
     | 
    
         
             
            description: ''
         
     | 
| 
       98 
98 
     | 
    
         
             
            email:
         
     | 
| 
       99 
     | 
    
         
            -
            -  
     | 
| 
      
 99 
     | 
    
         
            +
            - tech@groovenauts.jp
         
     | 
| 
       100 
100 
     | 
    
         
             
            executables:
         
     | 
| 
       101 
101 
     | 
    
         
             
            - magellan-rails
         
     | 
| 
       102 
102 
     | 
    
         
             
            extensions: []
         
     | 
| 
         @@ -104,6 +104,7 @@ extra_rdoc_files: [] 
     | 
|
| 
       104 
104 
     | 
    
         
             
            files:
         
     | 
| 
       105 
105 
     | 
    
         
             
            - ".gitignore"
         
     | 
| 
       106 
106 
     | 
    
         
             
            - ".rspec"
         
     | 
| 
      
 107 
     | 
    
         
            +
            - ChangeLog.md
         
     | 
| 
       107 
108 
     | 
    
         
             
            - Gemfile
         
     | 
| 
       108 
109 
     | 
    
         
             
            - LICENSE.txt
         
     | 
| 
       109 
110 
     | 
    
         
             
            - README.md
         
     | 
| 
         @@ -169,7 +170,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement 
     | 
|
| 
       169 
170 
     | 
    
         
             
                  version: '0'
         
     | 
| 
       170 
171 
     | 
    
         
             
            requirements: []
         
     | 
| 
       171 
172 
     | 
    
         
             
            rubyforge_project: 
         
     | 
| 
       172 
     | 
    
         
            -
            rubygems_version: 2.4. 
     | 
| 
      
 173 
     | 
    
         
            +
            rubygems_version: 2.4.5.1
         
     | 
| 
       173 
174 
     | 
    
         
             
            signing_key: 
         
     | 
| 
       174 
175 
     | 
    
         
             
            specification_version: 4
         
     | 
| 
       175 
176 
     | 
    
         
             
            summary: ''
         
     |