em-synchrony-moped 2.0.0.beta.1 → 2.0.0.beta.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.
- checksums.yaml +8 -8
- data/em-synchrony-moped.gemspec +1 -1
- data/lib/em-synchrony/moped/address.rb +5 -2
- data/lib/em-synchrony/moped.rb +1 -2
- metadata +1 -2
- data/lib/em-synchrony/moped/node.rb +0 -47
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
M2YxNzAyOGQzNGE4NWYwYTQ0ODBiNmYxNDZiNjI1YmM0NGQwMDczMg==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
Y2Y3MjAwZTI1YTJjMzdmNTNhN2M1ZDJhZTU3ZDVkMTg5ZTFhNTY5MQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
YTU3MDgwNDVjOTFlNmM2ZmY3NjI5NmE0MTQwNWYwYzE2MDIwMmQ2ZmJhODkz
|
10
|
+
YWU3ZTgxMmNlNmMyNTUxMGYzNGFhMGIyYzdkYzIzZGZhZmYwYWEwOTFkZmUw
|
11
|
+
YWIwNTFhYjdlZGUyMDQyMjEzYTk5OTZmZGMyMTA3ZGNlYWZmN2Y=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
NzE0MTU3YjQwNjk4OGYwOGVmNzZkZTY1ZGU3NTkyMDdhZGNlNDVlNDc5MGU2
|
14
|
+
NzU5N2RkMTcxNzg4MGIwOGVjMzE2MzJmMDQzNTM0MmI1ZjVlNDgyOWRkZTQ0
|
15
|
+
YzNhMWYwNzk4MmNmM2FmMTdlMzdlMzZjNGUyMzQyOGJkMDA3OWQ=
|
data/em-synchrony-moped.gemspec
CHANGED
@@ -1,4 +1,9 @@
|
|
1
1
|
# encoding: utf-8
|
2
|
+
|
3
|
+
require 'moped/address'
|
4
|
+
require 'em-dns-resolver'
|
5
|
+
require 'fiber'
|
6
|
+
|
2
7
|
module Moped
|
3
8
|
class Address
|
4
9
|
|
@@ -20,8 +25,6 @@ module Moped
|
|
20
25
|
end
|
21
26
|
|
22
27
|
def em_each_address(value)
|
23
|
-
puts "em_each_address: #{value.inspect}"
|
24
|
-
|
25
28
|
# Lookup in /etc/hosts
|
26
29
|
result = []
|
27
30
|
@hosts ||= Resolv::Hosts.new
|
data/lib/em-synchrony/moped.rb
CHANGED
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: 2.0.0.beta.
|
4
|
+
version: 2.0.0.beta.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Adam Lebsack
|
@@ -212,7 +212,6 @@ files:
|
|
212
212
|
- lib/em-synchrony/moped/address.rb
|
213
213
|
- lib/em-synchrony/moped/cluster.rb
|
214
214
|
- lib/em-synchrony/moped/connection.rb
|
215
|
-
- lib/em-synchrony/moped/node.rb
|
216
215
|
- spec/lib/em-synchrony/moped/cluster_spec.rb
|
217
216
|
- spec/lib/em-synchrony/moped/connection_spec.rb
|
218
217
|
- spec/lib/em-synchrony/moped/node_spec.rb
|
@@ -1,47 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'moped/node'
|
4
|
-
require 'em-dns-resolver'
|
5
|
-
require 'fiber'
|
6
|
-
|
7
|
-
module Moped
|
8
|
-
# # Our monkey patches to Moped::Node
|
9
|
-
class Node
|
10
|
-
if Moped::VERSION < "2.0.0"
|
11
|
-
alias_method :super_parse_address, :parse_address
|
12
|
-
# Override to support non-blocking DNS requests
|
13
|
-
def parse_address
|
14
|
-
return super_parse_address unless EventMachine.reactor_thread?
|
15
|
-
host, port = address.split(':')
|
16
|
-
@port = (port || 27_017).to_i
|
17
|
-
|
18
|
-
@ip_address = em_lookup_address(host).grep(/(::){0}/).first
|
19
|
-
fail SocketError unless @ip_address
|
20
|
-
@resolved_address = "#{@ip_address}:#{@port}"
|
21
|
-
rescue Resolv::ResolvError
|
22
|
-
raise SocketError
|
23
|
-
end
|
24
|
-
|
25
|
-
def em_lookup_address(value)
|
26
|
-
# Lookup in /etc/hosts
|
27
|
-
result = []
|
28
|
-
@hosts ||= Resolv::Hosts.new
|
29
|
-
@hosts.send(:each_address, value) { |x| result << x.to_s if x !~ /::/ }
|
30
|
-
return result unless result.empty?
|
31
|
-
|
32
|
-
# Nothing, hit DNS
|
33
|
-
fiber = Fiber.current
|
34
|
-
df = EM::DnsResolver.send(:resolve, value)
|
35
|
-
df.callback do |a|
|
36
|
-
fiber.resume(a)
|
37
|
-
end
|
38
|
-
df.errback do |*a|
|
39
|
-
fiber.resume(Resolv::ResolvError.new(a.inspect))
|
40
|
-
end
|
41
|
-
result = Fiber.yield
|
42
|
-
fail result if result.is_a?(StandardError)
|
43
|
-
result
|
44
|
-
end
|
45
|
-
end
|
46
|
-
end
|
47
|
-
end
|