magellan-rails 0.0.2 → 0.0.3
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/.gitignore +1 -0
- data/gems/magellan-publisher/.gitignore +1 -0
- data/gems/magellan-publisher/lib/magellan/publisher/version.rb +1 -1
- data/gems/magellan-publisher/lib/magellan/publisher.rb +44 -7
- data/gems/magellan-publisher/magellan-publisher.gemspec +1 -1
- data/gems/magellan-publisher/spec/magellan/publisher_spec.rb +49 -24
- data/lib/magellan/rails/version.rb +1 -1
- data/lib/magellan/subscriber/mapper.rb +2 -2
- data/lib/magellan/worker/config.rb +21 -7
- data/lib/magellan/worker/core.rb +1 -1
- data/lib/magellan/worker/executor.rb +0 -5
- data/lib/magellan.rb +5 -1
- data/spec/magellan/subscriber/mapper_spec.rb +13 -13
- metadata +2 -6
- data/Gemfile.lock +0 -76
- data/gems/magellan-publisher/Gemfile.lock +0 -51
- data/lib/generators/install_generator.rb +0 -20
- data/lib/generators/templates/Magellan.yml +0 -115
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f7994198ac677aac97cb9cd7607af3e1555f6835
|
4
|
+
data.tar.gz: 5aba22c79480da7e3e9725914069a0f4e05c9256
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0e16ac47ff948dbfbc28cb27d74d64e158aa89ecc7582638c180a7f1c21eab794e0dfd72d789e07a05e127e04349e71307192390399cab5e31b755ccee9191f0
|
7
|
+
data.tar.gz: e5d9df628af9e34942993fe8c344b42f0be2409cf3e57423477f42a544078e5fe2eb06ff8e09ad619656060737f6c04f47e4a01cf969509a4b5b7d64eec83612
|
data/.gitignore
CHANGED
@@ -2,15 +2,15 @@
|
|
2
2
|
|
3
3
|
module Magellan
|
4
4
|
class Publisher
|
5
|
-
def initialize(host:
|
5
|
+
def initialize(host: nil, port: nil, vhost: nil, user: nil, pass: nil, timeout: nil)
|
6
6
|
# RabbitMQへの接続設定を作成
|
7
7
|
connection_settings = {
|
8
|
-
host: host,
|
9
|
-
port: port,
|
10
|
-
vhost: vhost,
|
11
|
-
user: user,
|
12
|
-
pass: pass,
|
13
|
-
timeout: timeout,
|
8
|
+
host: load_env_as_default(host, ['MAGELLAN_PUBLISH_AMQP_ADDR'], :string),
|
9
|
+
port: load_env_as_default(port, ['MAGELLAN_PUBLISH_AMQP_PORT'], :integer),
|
10
|
+
vhost: load_env_as_default(vhost, ['MAGELLAN_PUBLISH_AMQP_VHOST'], :string),
|
11
|
+
user: load_env_as_default(user, ['MAGELLAN_PUBLISH_AMQP_USER'], :string),
|
12
|
+
pass: load_env_as_default(pass, ['MAGELLAN_PUBLISH_AMQP_PASS'], :string),
|
13
|
+
timeout: load_env_as_default(timeout, ['MAGELLAN_PUBLISH_AMQP_TIMEOUT'], :float) || 0.3,
|
14
14
|
}
|
15
15
|
|
16
16
|
@conn = Bunny.new(connection_settings)
|
@@ -33,5 +33,42 @@ module Magellan
|
|
33
33
|
def publish(topic, body)
|
34
34
|
@exchange.publish(body, routing_key: convert_topic(topic))
|
35
35
|
end
|
36
|
+
|
37
|
+
class << self
|
38
|
+
def publisher
|
39
|
+
@publisher ||= Magellan::Publisher.new
|
40
|
+
end
|
41
|
+
|
42
|
+
def publish(topic, body)
|
43
|
+
publisher.publish(topic, body)
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
private
|
48
|
+
|
49
|
+
def load_env_as_default(val, envkeys, type)
|
50
|
+
if is_blank?(val)
|
51
|
+
envkeys = Array(envkeys)
|
52
|
+
envkeys.each do |key|
|
53
|
+
val = ENV[key.to_s]
|
54
|
+
break if val and not(val.empty?)
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
58
|
+
if val
|
59
|
+
case type.to_sym
|
60
|
+
when :string then val.to_s
|
61
|
+
when :integer then Integer(val)
|
62
|
+
when :float then Float(val)
|
63
|
+
else val
|
64
|
+
end
|
65
|
+
else
|
66
|
+
nil
|
67
|
+
end
|
68
|
+
end
|
69
|
+
|
70
|
+
def is_blank?(val)
|
71
|
+
val.respond_to?(:empty?) ? !!val.empty? : !val
|
72
|
+
end
|
36
73
|
end
|
37
74
|
end
|
@@ -22,6 +22,6 @@ Gem::Specification.new do |spec|
|
|
22
22
|
spec.add_runtime_dependency "json"
|
23
23
|
|
24
24
|
spec.add_development_dependency "bundler", "~> 1.6"
|
25
|
+
spec.add_development_dependency "rake"
|
25
26
|
spec.add_development_dependency "rspec"
|
26
|
-
spec.add_development_dependency "bunny_mock"
|
27
27
|
end
|
@@ -9,31 +9,56 @@ describe Magellan::Publisher do
|
|
9
9
|
|
10
10
|
describe "#publish" do
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
allow(Bunny ).to receive(:new).and_return(@bunny)
|
22
|
-
allow(@bunny ).to receive(:create_channel).and_return(channel)
|
23
|
-
allow(channel).to receive(:exchange).with('test_exchange', no_declare: true).and_return(@exchange)
|
24
|
-
|
25
|
-
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
|
-
end
|
32
|
-
|
33
|
-
it do
|
34
|
-
@publisher.publish(@topic, @payload)
|
35
|
-
end
|
12
|
+
before do
|
13
|
+
@topic = "topic/aaa"
|
14
|
+
@rabbitmq_topic = "topic.aaa"
|
15
|
+
@payload = "Hello World"
|
16
|
+
@bunny = BunnyMock.new
|
17
|
+
channel = @bunny.create_channel
|
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)
|
36
20
|
|
21
|
+
allow(Bunny ).to receive(:new).and_return(@bunny)
|
22
|
+
allow(@bunny ).to receive(:create_channel).and_return(channel)
|
23
|
+
allow(channel).to receive(:exchange).with('test_exchange', no_declare: true).and_return(@exchange)
|
37
24
|
|
25
|
+
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
|
+
end
|
32
|
+
|
33
|
+
it do
|
34
|
+
@publisher.publish(@topic, @payload)
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
describe ".publish" do
|
39
|
+
before do
|
40
|
+
@topic = "topic/aaa"
|
41
|
+
@rabbitmq_topic = "topic.aaa"
|
42
|
+
@payload = "Hello World"
|
43
|
+
@bunny = BunnyMock.new
|
44
|
+
channel = @bunny.create_channel
|
45
|
+
@exchange = @bunny.exchange('test_exchange', type: :direct, durable: false, auto_delete: false)
|
46
|
+
expect(@exchange).to receive(:publish).with(@payload, routing_key: @rabbitmq_topic)
|
47
|
+
|
48
|
+
allow(Bunny ).to receive(:new).and_return(@bunny)
|
49
|
+
allow(@bunny ).to receive(:create_channel).and_return(channel)
|
50
|
+
allow(channel).to receive(:exchange).with('test_exchange', no_declare: true).and_return(@exchange)
|
51
|
+
|
52
|
+
ENV["MAGELLAN_PUBLISH_EXCHANGE"] = "test_exchange"
|
53
|
+
ENV["MAGELLAN_PUBLISH_AMQP_ADDR"] = "127.0.0.1"
|
54
|
+
ENV["MAGELLAN_PUBLISH_AMQP_PORT"] = "5672"
|
55
|
+
ENV["MAGELLAN_PUBLISH_AMQP_VHOST"] = "/customer1.sample_project"
|
56
|
+
ENV["MAGELLAN_PUBLISH_AMQP_USER"] = "customer1.sample_project"
|
57
|
+
ENV["MAGELLAN_PUBLISH_AMQP_PASS"] = "pasw1"
|
58
|
+
end
|
59
|
+
|
60
|
+
it do
|
61
|
+
Magellan::Publisher.publish(@topic, @payload)
|
62
|
+
end
|
38
63
|
end
|
39
64
|
end
|
@@ -71,7 +71,7 @@ class Magellan::Subscriber::Mapper
|
|
71
71
|
@map = config.each_with_object({}) do |(key, value), tbl|
|
72
72
|
regexp = topic_regexp(key)
|
73
73
|
controller, action = value.split("#", 2)
|
74
|
-
controller_name = (controller.
|
74
|
+
controller_name = (controller.camelize + "Subscriber")
|
75
75
|
tbl[regexp] = [controller_name, action]
|
76
76
|
end
|
77
77
|
end
|
@@ -96,7 +96,7 @@ class Magellan::Subscriber::Mapper
|
|
96
96
|
actions.each do |controller_name, action|
|
97
97
|
controller_class = ActiveSupport::Dependencies.constantize(controller_name)
|
98
98
|
controller = controller_class.new(request)
|
99
|
-
|
99
|
+
controller.process_action(action)
|
100
100
|
end
|
101
101
|
if actions.empty?
|
102
102
|
raise Magellan::Subscriber::RoutingError, "topic #{request.topic} has no matched subscriber"
|
@@ -16,17 +16,31 @@ module Magellan::Worker::Config
|
|
16
16
|
end
|
17
17
|
end
|
18
18
|
|
19
|
+
def env_compatible(new_env, old_env)
|
20
|
+
if ENV[new_env].present?
|
21
|
+
ENV[new_env]
|
22
|
+
else
|
23
|
+
ENV[old_env]
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
19
27
|
def load_config()
|
20
28
|
config = {}
|
21
|
-
config[:host] =
|
22
|
-
config[:port] =
|
23
|
-
config[:vhost] =
|
24
|
-
config[:rabbitmq_user] =
|
25
|
-
config[:rabbitmq_password] =
|
26
|
-
config[:request_queue] =
|
27
|
-
config[:response_exchange] =
|
29
|
+
config[:host] = env_compatible('MAGELLAN_WORKER_AMQP_ADDR', 'RABBITMQ_PORT_5672_TCP_ADDR')
|
30
|
+
config[:port] = env_compatible('MAGELLAN_WORKER_AMQP_PORT', 'RABBITMQ_PORT_5672_TCP_PORT')
|
31
|
+
config[:vhost] = env_compatible('MAGELLAN_WORKER_AMQP_VHOST', 'VHOST')
|
32
|
+
config[:rabbitmq_user] = env_compatible('MAGELLAN_WORKER_AMQP_USER', 'RABBITMQ_USER')
|
33
|
+
config[:rabbitmq_password] = env_compatible('MAGELLAN_WORKER_AMQP_PASS', 'RABBITMQ_PASS')
|
34
|
+
config[:request_queue] = env_compatible('MAGELLAN_WORKER_REQUEST_QUEUE', 'REQUEST_QUEUE')
|
35
|
+
config[:response_exchange] = env_compatible('MAGELLAN_WORKER_RESPONSE_EXCHANGE', 'RESPONSE_EXCHANGE')
|
28
36
|
config[:http_worker] = parse_boolean(ENV['MAGELLAN_HTTP_WORKER'], true)
|
29
37
|
config[:subscriber_worker] = parse_boolean(ENV['MAGELLAN_SUBSCRIBER_WORKER'], true)
|
38
|
+
config[:publish_host] = ENV["MAGELLAN_PUBLISH_AMQP_ADDR"]
|
39
|
+
config[:publish_port] = ENV["MAGELLAN_PUBLISH_AMQP_PORT"]
|
40
|
+
config[:publish_vhost] = ENV["MAGELLAN_PUBLISH_AMQP_VHOST"]
|
41
|
+
config[:publish_user] = ENV["MAGELLAN_PUBLISH_AMQP_USER"]
|
42
|
+
config[:publish_password] = ENV["MAGELLAN_PUBLISH_AMQP_PASS"]
|
43
|
+
config[:publish_exchange] = ENV["MAGELLAN_PUBLISH_EXCHANGE"]
|
30
44
|
config
|
31
45
|
end
|
32
46
|
end
|
data/lib/magellan/worker/core.rb
CHANGED
@@ -46,7 +46,7 @@ class Magellan::Worker::Core
|
|
46
46
|
|
47
47
|
def run
|
48
48
|
Magellan.logger.info("====== Magellan Worker start ======")
|
49
|
-
@queue.subscribe(block: true,
|
49
|
+
@queue.subscribe(block: true, manual_ack: true) do |delivery_info, properties, payload|
|
50
50
|
reply_to = properties.reply_to # ワーカー実行結果返却時のルーティングキー
|
51
51
|
correlation_id = properties.correlation_id # ワーカー実行結果返却時にどのリクエストに対応するメッセージか判別するための識別子
|
52
52
|
delivery_tag = delivery_info.delivery_tag # ackを返却時に使用
|
@@ -12,11 +12,6 @@ class Magellan::Worker::Executor
|
|
12
12
|
# Rails 環境の初期化は Subscriber だけの時も実施する
|
13
13
|
# Rails.root やら Rails.application.config がないと困ることが多いと思うので
|
14
14
|
require File.expand_path('config/environment')
|
15
|
-
|
16
|
-
# production 環境で subscriber として動作する時は eager loading しておく
|
17
|
-
if Rails.env.production? and Magellan::Worker.worker.config[:subscriber_worker]
|
18
|
-
subscriber_executor
|
19
|
-
end
|
20
15
|
end
|
21
16
|
|
22
17
|
def rails_executor
|
data/lib/magellan.rb
CHANGED
@@ -13,7 +13,11 @@ module Magellan
|
|
13
13
|
environment = ENV['RAILS_ENV'] || 'development'
|
14
14
|
log_dir = File.expand_path("log")
|
15
15
|
FileUtils.makedirs(log_dir) unless File.exists?(log_dir)
|
16
|
-
|
16
|
+
if environment == "production"
|
17
|
+
logger = ::Logger.new($stdout)
|
18
|
+
else
|
19
|
+
logger = ::Logger.new(File.expand_path("log/#{environment}.log"))
|
20
|
+
end
|
17
21
|
|
18
22
|
log_level_env = ENV['MAGELLAN_RAILS_LOG_LEVEL']
|
19
23
|
log_levels = ['debug', 'info', 'warn', 'error', 'fatal', 'unknown']
|
@@ -18,7 +18,7 @@ describe Magellan::Subscriber::Mapper do
|
|
18
18
|
context "matches" do
|
19
19
|
[ "a" ].each do |word|
|
20
20
|
it "'#{word}'" do
|
21
|
-
expect(@mapper.map_action(word)).to eql([["
|
21
|
+
expect(@mapper.map_action(word)).to eql([["BooksSubscriber", "index"]])
|
22
22
|
end
|
23
23
|
end
|
24
24
|
end
|
@@ -37,7 +37,7 @@ describe Magellan::Subscriber::Mapper do
|
|
37
37
|
end
|
38
38
|
context "matches" do
|
39
39
|
it "'a/b'" do
|
40
|
-
expect(@mapper.map_action("a/b")).to eql([["
|
40
|
+
expect(@mapper.map_action("a/b")).to eql([["BooksSubscriber", "index"]])
|
41
41
|
end
|
42
42
|
end
|
43
43
|
context "doesn't match" do
|
@@ -55,7 +55,7 @@ describe Magellan::Subscriber::Mapper do
|
|
55
55
|
end
|
56
56
|
context "matches" do
|
57
57
|
it "'/a'" do
|
58
|
-
expect(@mapper.map_action("/a")).to eql([["
|
58
|
+
expect(@mapper.map_action("/a")).to eql([["BooksSubscriber", "index"]])
|
59
59
|
end
|
60
60
|
end
|
61
61
|
context "doesn't match" do
|
@@ -73,7 +73,7 @@ describe Magellan::Subscriber::Mapper do
|
|
73
73
|
end
|
74
74
|
context "matches" do
|
75
75
|
it "'a/'" do
|
76
|
-
expect(@mapper.map_action("a/")).to eql([["
|
76
|
+
expect(@mapper.map_action("a/")).to eql([["BooksSubscriber", "index"]])
|
77
77
|
end
|
78
78
|
end
|
79
79
|
context "doesn't match" do
|
@@ -92,7 +92,7 @@ describe Magellan::Subscriber::Mapper do
|
|
92
92
|
context "matches" do
|
93
93
|
[ "a", "b" ].each do |word|
|
94
94
|
it "'#{word}'" do
|
95
|
-
expect(@mapper.map_action(word)).to eql([["
|
95
|
+
expect(@mapper.map_action(word)).to eql([["BooksSubscriber", "index"]])
|
96
96
|
end
|
97
97
|
end
|
98
98
|
end
|
@@ -112,7 +112,7 @@ describe Magellan::Subscriber::Mapper do
|
|
112
112
|
context "matches" do
|
113
113
|
[ "a/a", "b/a" ].each do |word|
|
114
114
|
it "'#{word}'" do
|
115
|
-
expect(@mapper.map_action(word)).to eql([["
|
115
|
+
expect(@mapper.map_action(word)).to eql([["BooksSubscriber", "index"]])
|
116
116
|
end
|
117
117
|
end
|
118
118
|
end
|
@@ -132,7 +132,7 @@ describe Magellan::Subscriber::Mapper do
|
|
132
132
|
context "matches" do
|
133
133
|
[ "a/a", "a/b" ].each do |word|
|
134
134
|
it "'#{word}'" do
|
135
|
-
expect(@mapper.map_action(word)).to eql([["
|
135
|
+
expect(@mapper.map_action(word)).to eql([["BooksSubscriber", "index"]])
|
136
136
|
end
|
137
137
|
end
|
138
138
|
end
|
@@ -152,7 +152,7 @@ describe Magellan::Subscriber::Mapper do
|
|
152
152
|
context "matches" do
|
153
153
|
[ "a/a/b", "a/c/b" ].each do |word|
|
154
154
|
it "'#{word}'" do
|
155
|
-
expect(@mapper.map_action(word)).to eql([["
|
155
|
+
expect(@mapper.map_action(word)).to eql([["BooksSubscriber", "index"]])
|
156
156
|
end
|
157
157
|
end
|
158
158
|
end
|
@@ -172,7 +172,7 @@ describe Magellan::Subscriber::Mapper do
|
|
172
172
|
context "matches" do
|
173
173
|
[ "a", "/a", "a/", "/", "a/b", "a/b/c", "/a/b/c/" ].each do |word|
|
174
174
|
it "'#{word}'" do
|
175
|
-
expect(@mapper.map_action(word)).to eql([["
|
175
|
+
expect(@mapper.map_action(word)).to eql([["BooksSubscriber", "index"]])
|
176
176
|
end
|
177
177
|
end
|
178
178
|
end
|
@@ -185,7 +185,7 @@ describe Magellan::Subscriber::Mapper do
|
|
185
185
|
context "matches" do
|
186
186
|
[ "a", "a/b", "a/b/c", "a/", "a/b/" ].each do |word|
|
187
187
|
it "'#{word}'" do
|
188
|
-
expect(@mapper.map_action(word)).to eql([["
|
188
|
+
expect(@mapper.map_action(word)).to eql([["BooksSubscriber", "index"]])
|
189
189
|
end
|
190
190
|
end
|
191
191
|
end
|
@@ -205,7 +205,7 @@ describe Magellan::Subscriber::Mapper do
|
|
205
205
|
context "matches" do
|
206
206
|
[ "a/b", "a/b/", "a/b/c", "a/b/c/d" ].each do |word|
|
207
207
|
it "'#{word}'" do
|
208
|
-
expect(@mapper.map_action(word)).to eql([["
|
208
|
+
expect(@mapper.map_action(word)).to eql([["BooksSubscriber", "index"]])
|
209
209
|
end
|
210
210
|
end
|
211
211
|
end
|
@@ -226,7 +226,7 @@ describe Magellan::Subscriber::Mapper do
|
|
226
226
|
context "matches" do
|
227
227
|
[ "a/b", "a/c/b", "a/c/d/b" ].each do |word|
|
228
228
|
it "'#{word}'" do
|
229
|
-
expect(@mapper.map_action(word)).to eql([["
|
229
|
+
expect(@mapper.map_action(word)).to eql([["BooksSubscriber", "index"]])
|
230
230
|
end
|
231
231
|
end
|
232
232
|
end
|
@@ -246,7 +246,7 @@ describe Magellan::Subscriber::Mapper do
|
|
246
246
|
context "matches" do
|
247
247
|
[ "a", "/a", "b/a", "/b/a", "c/b/a" ].each do |word|
|
248
248
|
it "'#{word}'" do
|
249
|
-
expect(@mapper.map_action(word)).to eql([["
|
249
|
+
expect(@mapper.map_action(word)).to eql([["BooksSubscriber", "index"]])
|
250
250
|
end
|
251
251
|
end
|
252
252
|
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.0.
|
4
|
+
version: 0.0.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: 2014-
|
11
|
+
date: 2014-12-11 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: railties
|
@@ -90,14 +90,12 @@ extra_rdoc_files: []
|
|
90
90
|
files:
|
91
91
|
- ".gitignore"
|
92
92
|
- Gemfile
|
93
|
-
- Gemfile.lock
|
94
93
|
- LICENSE.txt
|
95
94
|
- README.md
|
96
95
|
- Rakefile
|
97
96
|
- bin/magellan-rails
|
98
97
|
- gems/magellan-publisher/.gitignore
|
99
98
|
- gems/magellan-publisher/Gemfile
|
100
|
-
- gems/magellan-publisher/Gemfile.lock
|
101
99
|
- gems/magellan-publisher/LICENSE.txt
|
102
100
|
- gems/magellan-publisher/README.md
|
103
101
|
- gems/magellan-publisher/Rakefile
|
@@ -106,8 +104,6 @@ files:
|
|
106
104
|
- gems/magellan-publisher/magellan-publisher.gemspec
|
107
105
|
- gems/magellan-publisher/spec/magellan/publisher_spec.rb
|
108
106
|
- gems/magellan-publisher/spec/spec_helper.rb
|
109
|
-
- lib/generators/install_generator.rb
|
110
|
-
- lib/generators/templates/Magellan.yml
|
111
107
|
- lib/magellan.rb
|
112
108
|
- lib/magellan/extentions.rb
|
113
109
|
- lib/magellan/extentions/rails.rb
|
data/Gemfile.lock
DELETED
@@ -1,76 +0,0 @@
|
|
1
|
-
GIT
|
2
|
-
remote: git://github.com/groovenauts/bunny-mock.git
|
3
|
-
revision: fbc775600d1e68b4bd3a521ca762ba79f3571704
|
4
|
-
branch: features/minimum_necessary_mock
|
5
|
-
specs:
|
6
|
-
bunny_mock (0.0.1)
|
7
|
-
|
8
|
-
PATH
|
9
|
-
remote: .
|
10
|
-
specs:
|
11
|
-
magellan-rails (0.0.2)
|
12
|
-
bunny
|
13
|
-
json
|
14
|
-
railties (~> 4.1.0)
|
15
|
-
|
16
|
-
GEM
|
17
|
-
remote: https://rubygems.org/
|
18
|
-
specs:
|
19
|
-
actionpack (4.1.6)
|
20
|
-
actionview (= 4.1.6)
|
21
|
-
activesupport (= 4.1.6)
|
22
|
-
rack (~> 1.5.2)
|
23
|
-
rack-test (~> 0.6.2)
|
24
|
-
actionview (4.1.6)
|
25
|
-
activesupport (= 4.1.6)
|
26
|
-
builder (~> 3.1)
|
27
|
-
erubis (~> 2.7.0)
|
28
|
-
activesupport (4.1.6)
|
29
|
-
i18n (~> 0.6, >= 0.6.9)
|
30
|
-
json (~> 1.7, >= 1.7.7)
|
31
|
-
minitest (~> 5.1)
|
32
|
-
thread_safe (~> 0.1)
|
33
|
-
tzinfo (~> 1.1)
|
34
|
-
amq-protocol (1.9.2)
|
35
|
-
builder (3.2.2)
|
36
|
-
bunny (1.5.0)
|
37
|
-
amq-protocol (>= 1.9.2)
|
38
|
-
diff-lcs (1.2.5)
|
39
|
-
erubis (2.7.0)
|
40
|
-
i18n (0.6.11)
|
41
|
-
json (1.8.1)
|
42
|
-
minitest (5.4.2)
|
43
|
-
rack (1.5.2)
|
44
|
-
rack-test (0.6.2)
|
45
|
-
rack (>= 1.0)
|
46
|
-
railties (4.1.6)
|
47
|
-
actionpack (= 4.1.6)
|
48
|
-
activesupport (= 4.1.6)
|
49
|
-
rake (>= 0.8.7)
|
50
|
-
thor (>= 0.18.1, < 2.0)
|
51
|
-
rake (10.3.2)
|
52
|
-
rspec (3.0.0)
|
53
|
-
rspec-core (~> 3.0.0)
|
54
|
-
rspec-expectations (~> 3.0.0)
|
55
|
-
rspec-mocks (~> 3.0.0)
|
56
|
-
rspec-core (3.0.3)
|
57
|
-
rspec-support (~> 3.0.0)
|
58
|
-
rspec-expectations (3.0.3)
|
59
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
60
|
-
rspec-support (~> 3.0.0)
|
61
|
-
rspec-mocks (3.0.3)
|
62
|
-
rspec-support (~> 3.0.0)
|
63
|
-
rspec-support (3.0.3)
|
64
|
-
thor (0.19.1)
|
65
|
-
thread_safe (0.3.4)
|
66
|
-
tzinfo (1.2.2)
|
67
|
-
thread_safe (~> 0.1)
|
68
|
-
|
69
|
-
PLATFORMS
|
70
|
-
ruby
|
71
|
-
|
72
|
-
DEPENDENCIES
|
73
|
-
bundler (~> 1.6)
|
74
|
-
bunny_mock!
|
75
|
-
magellan-rails!
|
76
|
-
rspec
|
@@ -1,51 +0,0 @@
|
|
1
|
-
GIT
|
2
|
-
remote: git://github.com/groovenauts/bunny-mock.git
|
3
|
-
revision: fbc775600d1e68b4bd3a521ca762ba79f3571704
|
4
|
-
branch: features/minimum_necessary_mock
|
5
|
-
specs:
|
6
|
-
bunny_mock (0.0.1)
|
7
|
-
|
8
|
-
PATH
|
9
|
-
remote: .
|
10
|
-
specs:
|
11
|
-
magellan-publisher (0.0.1)
|
12
|
-
bunny
|
13
|
-
json
|
14
|
-
|
15
|
-
GEM
|
16
|
-
remote: https://rubygems.org/
|
17
|
-
specs:
|
18
|
-
amq-protocol (1.9.2)
|
19
|
-
bunny (1.4.1)
|
20
|
-
amq-protocol (>= 1.9.2)
|
21
|
-
diff-lcs (1.2.5)
|
22
|
-
docile (1.1.5)
|
23
|
-
json (1.8.1)
|
24
|
-
multi_json (1.10.1)
|
25
|
-
rspec (3.1.0)
|
26
|
-
rspec-core (~> 3.1.0)
|
27
|
-
rspec-expectations (~> 3.1.0)
|
28
|
-
rspec-mocks (~> 3.1.0)
|
29
|
-
rspec-core (3.1.6)
|
30
|
-
rspec-support (~> 3.1.0)
|
31
|
-
rspec-expectations (3.1.2)
|
32
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
33
|
-
rspec-support (~> 3.1.0)
|
34
|
-
rspec-mocks (3.1.3)
|
35
|
-
rspec-support (~> 3.1.0)
|
36
|
-
rspec-support (3.1.2)
|
37
|
-
simplecov (0.9.1)
|
38
|
-
docile (~> 1.1.0)
|
39
|
-
multi_json (~> 1.0)
|
40
|
-
simplecov-html (~> 0.8.0)
|
41
|
-
simplecov-html (0.8.0)
|
42
|
-
|
43
|
-
PLATFORMS
|
44
|
-
ruby
|
45
|
-
|
46
|
-
DEPENDENCIES
|
47
|
-
bundler (~> 1.6)
|
48
|
-
bunny_mock!
|
49
|
-
magellan-publisher!
|
50
|
-
rspec
|
51
|
-
simplecov
|
@@ -1,20 +0,0 @@
|
|
1
|
-
require 'rails/generators/base'
|
2
|
-
require 'securerandom'
|
3
|
-
|
4
|
-
module Magellan
|
5
|
-
module Generators
|
6
|
-
class InstallGenerator < ::Rails::Generators::Base
|
7
|
-
source_root File.expand_path("../templates", __FILE__)
|
8
|
-
|
9
|
-
desc "Creates config files for Magellan"
|
10
|
-
|
11
|
-
def copy_magellan_yaml
|
12
|
-
template "Magellan.yml", "Magellan.yml"
|
13
|
-
end
|
14
|
-
|
15
|
-
def rails_4?
|
16
|
-
::Rails::VERSION::MAJOR == 4
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
@@ -1,115 +0,0 @@
|
|
1
|
-
trdb:
|
2
|
-
image: redis:2.8.13
|
3
|
-
# Dockerfile: https://raw.githubusercontent.com/docker-library/redis/docker-2.8.12/Dockerfile
|
4
|
-
after_tasks:
|
5
|
-
- name: "setup TD data"
|
6
|
-
docker:
|
7
|
-
detach: False
|
8
|
-
name: magellan-tr-data
|
9
|
-
image: groovenauts/magellan-tr-data
|
10
|
-
links:
|
11
|
-
- trdb:redis
|
12
|
-
|
13
|
-
|
14
|
-
rabbitmq:
|
15
|
-
before_tasks:
|
16
|
-
- name: "stop RabbitMQ container"
|
17
|
-
command: docker stop rabbitmq
|
18
|
-
ignore_errors: yes
|
19
|
-
- name: "remove RabbitMQ container"
|
20
|
-
command: docker rm rabbitmq
|
21
|
-
ignore_errors: yes
|
22
|
-
|
23
|
-
- name: "make RabbitMQ log directory"
|
24
|
-
file:
|
25
|
-
path: /var/log/rabbitmq
|
26
|
-
force: yes
|
27
|
-
state: directory
|
28
|
-
|
29
|
-
- name: "change owner /var/log/rabbitmq to rabbitmq"
|
30
|
-
docker:
|
31
|
-
name: rabbitmq_dir_owner
|
32
|
-
image: tutum/rabbitmq
|
33
|
-
volumes:
|
34
|
-
- /var/log/rabbitmq:/var/log/rabbitmq
|
35
|
-
command: "chown -R rabbitmq:rabbitmq /var/log/rabbitmq"
|
36
|
-
|
37
|
-
image: tutum/rabbitmq
|
38
|
-
# Dockerfile: https://raw.githubusercontent.com/tutumcloud/tutum-docker-rabbitmq/master/Dockerfile
|
39
|
-
ports:
|
40
|
-
- 5672:5672
|
41
|
-
- 15672:15672
|
42
|
-
env:
|
43
|
-
- RABBITMQ_USER=magellan
|
44
|
-
- RABBITMQ_PASS=mypass
|
45
|
-
volumes:
|
46
|
-
- /var/log/rabbitmq:/var/log/rabbitmq
|
47
|
-
|
48
|
-
after_tasks:
|
49
|
-
- name: "wait to ready rabbitmq"
|
50
|
-
wait_for: delay=3 port=5672
|
51
|
-
- name: "wait to ready rabbitmq admin"
|
52
|
-
wait_for: port=15672
|
53
|
-
- name: "setup Queues and Exchanges"
|
54
|
-
docker:
|
55
|
-
detach: False
|
56
|
-
name: magellan-setup_tools
|
57
|
-
image: groovenauts/magellan-setup_tools:0.1.1
|
58
|
-
links:
|
59
|
-
- trdb:redis
|
60
|
-
- rabbitmq:rabbitmq
|
61
|
-
command: ruby ./rabbitmq customer1.magellan-rails-example 0.0.1 rails transaction-router pswd1 pswd2
|
62
|
-
|
63
|
-
|
64
|
-
tr:
|
65
|
-
before_tasks:
|
66
|
-
- name: "stop tr container"
|
67
|
-
command: docker stop tr
|
68
|
-
ignore_errors: yes
|
69
|
-
- name: "remove tr container"
|
70
|
-
command: docker rm tr
|
71
|
-
ignore_errors: yes
|
72
|
-
|
73
|
-
image: groovenauts/magellan-transaction-router:0.0.1-with_signature
|
74
|
-
# Dockerfile: https://raw.githubusercontent.com/tengine/magellan-transaction-router-broadleaf/feature/integration01/Dockerfile?token=18912__eyJzY29wZSI6IlJhd0Jsb2I6dGVuZ2luZS9tYWdlbGxhbi10cmFuc2FjdGlvbi1yb3V0ZXItYnJvYWRsZWFmL2ZlYXR1cmUvaW50ZWdyYXRpb24wMS9Eb2NrZXJmaWxlIiwiZXhwaXJlcyI6MTQwNzIzMDg4MX0%3D--2ca5fb4de69eca8cbc5cda747b8716ed85ce89a2
|
75
|
-
ports:
|
76
|
-
- 3000:3000
|
77
|
-
links:
|
78
|
-
- trdb:redis
|
79
|
-
- rabbitmq:rabbitmq
|
80
|
-
tty: True
|
81
|
-
stdin_open: True
|
82
|
-
command: /bin/bash ./boot.sh
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
87
|
-
app:
|
88
|
-
before_tasks:
|
89
|
-
- name: "stop app container"
|
90
|
-
command: docker stop app
|
91
|
-
ignore_errors: yes
|
92
|
-
- name: "remove app container"
|
93
|
-
command: docker rm app
|
94
|
-
ignore_errors: yes
|
95
|
-
|
96
|
-
- name: "make application log directory"
|
97
|
-
file:
|
98
|
-
path: /var/log/application
|
99
|
-
force: yes
|
100
|
-
state: directory
|
101
|
-
|
102
|
-
image: groovenauts/magellan-rails-example
|
103
|
-
# Dockerfile: "./Dockerfile"
|
104
|
-
links:
|
105
|
-
- rabbitmq:rabbitmq
|
106
|
-
env:
|
107
|
-
- VHOST=/customer1.magellan-rails-example
|
108
|
-
- REQUEST_QUEUE=customer1.magellan-rails-example.0.0.1.rails
|
109
|
-
- RESPONSE_EXCHANGE=customer1.magellan-rails-example.reply
|
110
|
-
- RABBITMQ_USER=customer1.magellan-rails-example
|
111
|
-
- RABBITMQ_PASS=pswd2
|
112
|
-
- SECRET_KEY_BASE={{ app_secret_key_base }}
|
113
|
-
volumes:
|
114
|
-
- /var/log/application:/usr/src/app/log
|
115
|
-
command: bundle exec magellan-rails
|