em-synchrony-moped 0.9.1 → 0.9.2
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.
- data/em-synchrony-moped.gemspec +1 -1
- data/lib/em-synchrony/moped.rb +15 -0
- data/spec/moped_spec.rb +18 -0
- metadata +2 -2
data/em-synchrony-moped.gemspec
CHANGED
data/lib/em-synchrony/moped.rb
CHANGED
@@ -12,6 +12,18 @@ silence_warnings {
|
|
12
12
|
end
|
13
13
|
|
14
14
|
class Node
|
15
|
+
def resolve_address
|
16
|
+
begin
|
17
|
+
parse_address and true
|
18
|
+
rescue SocketError
|
19
|
+
if logger = Moped.logger
|
20
|
+
logger.warn " MOPED: Could not resolve IP address for #{address}"
|
21
|
+
end
|
22
|
+
@down_at = Time.new
|
23
|
+
false
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
15
27
|
# Override to support non-blocking DNS requests
|
16
28
|
def parse_address
|
17
29
|
host, port = address.split(":")
|
@@ -27,7 +39,10 @@ silence_warnings {
|
|
27
39
|
break
|
28
40
|
end
|
29
41
|
end
|
42
|
+
raise SocketError unless @ip_address
|
30
43
|
@resolved_address = "#{@ip_address}:#{@port}"
|
44
|
+
rescue Resolv::ResolvError
|
45
|
+
raise SocketError
|
31
46
|
end
|
32
47
|
end
|
33
48
|
|
data/spec/moped_spec.rb
CHANGED
@@ -10,6 +10,24 @@ describe "em-synchrony/moped" do
|
|
10
10
|
host = options.delete(:host) || 'localhost'
|
11
11
|
Moped::Node.new("#{host}:#{FakeMongodHelper::BASE_PORT}", options)
|
12
12
|
end
|
13
|
+
|
14
|
+
context "ip address caching" do
|
15
|
+
subject { new_node }
|
16
|
+
around do |block|
|
17
|
+
EventMachine.synchrony do
|
18
|
+
start_mongod
|
19
|
+
|
20
|
+
block.call
|
21
|
+
EM.stop
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
it "doesn't cache the ip_address" do
|
26
|
+
subject.ip_address == "10.0.0.1"
|
27
|
+
subject.should_receive(:parse_address)
|
28
|
+
subject.refresh
|
29
|
+
end
|
30
|
+
end
|
13
31
|
|
14
32
|
context "without ssl" do
|
15
33
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: em-synchrony-moped
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.
|
4
|
+
version: 0.9.2
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2013-05-
|
12
|
+
date: 2013-05-14 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: eventmachine
|