Module: Mcrain
- Defined in:
- lib/mcrain/mysql.rb,
lib/mcrain.rb,
lib/mcrain/base.rb,
lib/mcrain/riak.rb,
lib/mcrain/redis.rb,
lib/mcrain/version.rb,
lib/mcrain/rabbitmq.rb,
lib/mcrain/boot2docker.rb,
lib/mcrain/client_provider.rb,
lib/mcrain/container_controller.rb
Overview
don’t require ‘rabbitmq/http/client’ here in order to use mcrain without ‘rabbitmq_http_api_client’ gem require ‘rabbitmq/http/client’
Defined Under Namespace
Modules: Boot2docker, ClientProvider, ContainerController
Classes: Base, Mysql, Rabbitmq, Redis, Riak
Constant Summary
collapse
- DEFAULT_IMAGES =
{
mysql: "mysql:5.5",
redis: "redis:2.8.19",
rabbitmq: "rabbitmq:3.4.4-management",
riak: "hectcastro/riak",
}.freeze
- VERSION =
"0.3.3"
Class Attribute Summary collapse
Class Method Summary
collapse
Class Attribute Details
.images ⇒ Object
56
57
58
|
# File 'lib/mcrain.rb', line 56
def images
@images ||= DEFAULT_IMAGES.dup
end
|
.logger ⇒ Object
62
63
64
|
# File 'lib/mcrain.rb', line 62
def logger
@logger ||= Logger.new($stderr)
end
|
Class Method Details
.[](name) ⇒ Object
15
16
17
|
# File 'lib/mcrain.rb', line 15
def [](name)
lookup(name)
end
|
.class_for(name) ⇒ Object
30
31
32
33
34
35
36
37
38
39
|
# File 'lib/mcrain.rb', line 30
def class_for(name)
if class_name = class_names[name]
class_name.constantize
else
if klass = Mcrain::Base.descendants.detect{|c| c.server_name == name}
class_names[name] = klass.name
end
klass
end
end
|
.class_names ⇒ Object
26
27
28
|
# File 'lib/mcrain.rb', line 26
def class_names
@class_names ||= {}
end
|
.instances ⇒ Object
45
46
47
|
# File 'lib/mcrain.rb', line 45
def instances
@instances ||= {}
end
|
.lookup(name, options = {}) ⇒ Object
19
20
21
22
23
24
|
# File 'lib/mcrain.rb', line 19
def lookup(name, options = {})
klass = class_for(name.to_sym)
r = instances[name] ||= klass.new
options.each{|k,v| r.send("#{k}=", v)}
r
end
|
.register(name, class_name) ⇒ Object
41
42
43
|
# File 'lib/mcrain.rb', line 41
def register(name, class_name)
class_names[name] = class_name
end
|
.wait_port_opened(host, port, options = {}) ⇒ Object
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
# File 'lib/mcrain.rb', line 66
def wait_port_opened(host, port, options = {})
logger.debug("wait_port_opened(#{host.inspect}, #{port.inspect}, #{options.inspect})")
interval = options[:interval] || 10 Timeout.timeout(options[:timeout] || 60) do
begin
s = TCPSocket.open(host, port)
s.close
return true
rescue Errno::ECONNREFUSED
sleep(interval)
retry
end
end
end
|