monga 0.0.5 → 0.0.6
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/lib/monga/clients/replica_set_client.rb +1 -3
- data/lib/monga/clients/single_instance_client.rb +0 -1
- data/lib/monga/connections/buffer.rb +4 -2
- data/lib/monga/connections/em_connection.rb +3 -3
- data/lib/monga/connections/em_proxy_connection.rb +6 -1
- data/lib/monga/connections/fibered_proxy_connection.rb +5 -0
- data/lib/monga/connections/proxy_connection.rb +4 -0
- data/monga.gemspec +1 -1
- data/spec/helpers/mongodb.rb +4 -4
- metadata +4 -4
@@ -14,7 +14,7 @@ module Monga::Clients
|
|
14
14
|
|
15
15
|
servers = opts.delete :servers
|
16
16
|
@clients = servers.map do |server|
|
17
|
-
|
17
|
+
case server
|
18
18
|
when Hash
|
19
19
|
Monga::Clients::SingleInstanceClient.new(opts.merge(server))
|
20
20
|
when String
|
@@ -22,8 +22,6 @@ module Monga::Clients
|
|
22
22
|
o = { host: h, port: p.to_i }
|
23
23
|
Monga::Clients::SingleInstanceClient.new(opts.merge(o))
|
24
24
|
end
|
25
|
-
c.force_status!
|
26
|
-
c
|
27
25
|
end
|
28
26
|
|
29
27
|
@proxy_connection = Monga::Connection.proxy_connection_class(opts[:type], self)
|
@@ -19,8 +19,10 @@ module Monga::Connections
|
|
19
19
|
end
|
20
20
|
|
21
21
|
def parse
|
22
|
-
|
23
|
-
|
22
|
+
begin
|
23
|
+
more = parse_meta if @position == 0
|
24
|
+
parse_doc if @position > 0
|
25
|
+
end while more && @position == 0
|
24
26
|
end
|
25
27
|
|
26
28
|
def parse_meta
|
@@ -25,7 +25,7 @@ module Monga::Connections
|
|
25
25
|
callback do
|
26
26
|
send_data msg
|
27
27
|
end
|
28
|
-
@responses[request_id] = cb
|
28
|
+
@responses[request_id] = cb if cb
|
29
29
|
end
|
30
30
|
|
31
31
|
def receive_data(data)
|
@@ -33,7 +33,7 @@ module Monga::Connections
|
|
33
33
|
@buffer.each do |message|
|
34
34
|
request_id = message[2]
|
35
35
|
cb = @responses.delete request_id
|
36
|
-
cb.call(message)
|
36
|
+
cb.call(message) if cb
|
37
37
|
end
|
38
38
|
end
|
39
39
|
|
@@ -68,7 +68,7 @@ module Monga::Connections
|
|
68
68
|
end
|
69
69
|
|
70
70
|
def connected?
|
71
|
-
reconnect unless @
|
71
|
+
reconnect unless @connected
|
72
72
|
@connected || false
|
73
73
|
end
|
74
74
|
|
@@ -14,6 +14,10 @@ module Monga::Connections
|
|
14
14
|
@requests = {}
|
15
15
|
end
|
16
16
|
|
17
|
+
def type
|
18
|
+
:em
|
19
|
+
end
|
20
|
+
|
17
21
|
# If timeout is defined then collect request and start timeout.
|
18
22
|
# If timeout is not defined or zero then return exception.
|
19
23
|
def send_command(msg, request_id = nil, &cb)
|
@@ -22,7 +26,7 @@ module Monga::Connections
|
|
22
26
|
set_timeout unless @pending_timeout
|
23
27
|
find_server! unless @pending_server
|
24
28
|
else
|
25
|
-
error = Monga::Exceptions::Disconnected.new "Can't find appropriate server (all disconnected)"
|
29
|
+
error = Monga::Exceptions::Disconnected.new "Can't find appropriate server (all disconnected) without timeout"
|
26
30
|
cb.call(error) if cb
|
27
31
|
end
|
28
32
|
end
|
@@ -36,6 +40,7 @@ module Monga::Connections
|
|
36
40
|
|
37
41
|
def timeout_happend
|
38
42
|
@timeout_happend = false
|
43
|
+
@pending_timeout.cancel if @pending_timeout
|
39
44
|
@pending_timeout = false
|
40
45
|
@pending_server = false
|
41
46
|
@requests.keys.each do |request_id|
|
data/monga.gemspec
CHANGED
@@ -4,7 +4,7 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
|
5
5
|
Gem::Specification.new do |spec|
|
6
6
|
spec.name = "monga"
|
7
|
-
spec.version = "0.0.
|
7
|
+
spec.version = "0.0.6"
|
8
8
|
spec.authors = ["Petr Yanovich"]
|
9
9
|
spec.email = ["fl00r@yandex.ru"]
|
10
10
|
spec.description = %q{MongoDB Ruby Evented Driver on EventMachine}
|
data/spec/helpers/mongodb.rb
CHANGED
@@ -61,8 +61,7 @@ module Fake
|
|
61
61
|
end
|
62
62
|
|
63
63
|
def primary
|
64
|
-
|
65
|
-
pr
|
64
|
+
@si.rs.primary == @si if @si.rs
|
66
65
|
end
|
67
66
|
|
68
67
|
def receive_data(data)
|
@@ -93,12 +92,12 @@ module Fake
|
|
93
92
|
end
|
94
93
|
|
95
94
|
def start
|
96
|
-
@sign = EM.start_server('127.0.0.1', @port, Fake::Node, self)
|
95
|
+
@sign = EM.start_server('127.0.0.1', @port, Fake::Node, self) unless @connected
|
97
96
|
@connected = true
|
98
97
|
end
|
99
98
|
|
100
99
|
def stop
|
101
|
-
@server.close_connection
|
100
|
+
@server.close_connection if @server
|
102
101
|
EM.stop_server @sign
|
103
102
|
@connected = false
|
104
103
|
end
|
@@ -123,6 +122,7 @@ module Fake
|
|
123
122
|
|
124
123
|
def vote
|
125
124
|
@primary = @instances.select{|inst| inst.connected? }.sample
|
125
|
+
@primary
|
126
126
|
end
|
127
127
|
|
128
128
|
def primary
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: monga
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.6
|
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-04-
|
12
|
+
date: 2013-04-29 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
@@ -194,7 +194,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
194
194
|
requirements:
|
195
195
|
- - ! '>='
|
196
196
|
- !ruby/object:Gem::Version
|
197
|
-
hash:
|
197
|
+
hash: -3962526029351115610
|
198
198
|
version: '0'
|
199
199
|
segments:
|
200
200
|
- 0
|
@@ -203,7 +203,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
203
203
|
requirements:
|
204
204
|
- - ! '>='
|
205
205
|
- !ruby/object:Gem::Version
|
206
|
-
hash:
|
206
|
+
hash: -3962526029351115610
|
207
207
|
version: '0'
|
208
208
|
segments:
|
209
209
|
- 0
|