moped 2.0.0 → 2.0.1
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of moped might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/CHANGELOG.md +11 -0
- data/README.md +1 -1
- data/lib/moped/authenticatable.rb +12 -1
- data/lib/moped/cluster.rb +17 -5
- data/lib/moped/connection.rb +5 -2
- data/lib/moped/errors.rb +1 -1
- data/lib/moped/node.rb +3 -3
- data/lib/moped/session.rb +5 -0
- data/lib/moped/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 8fa0eef7f132d7a550f49134bd92a7b3ff4fa314
|
4
|
+
data.tar.gz: 156ccfc04d3f34face6722535bc9cbddfd60c24d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 178d8f39f368836fd846172eb03850c3bd193c31a6bb6ba7daae5003988faf0de71294be7123f329fe17181fc813f760c7b01e4b3932e667c196b346383d9758
|
7
|
+
data.tar.gz: 579ecfe14e1f22aa954cf55f2f935cae889d4d35d48d60eecb4c11123ecca7af2690d41b85797054cd01385b88e77aa59728709fd1a8609acb9d8cf576715177
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,16 @@
|
|
1
1
|
# Overview
|
2
2
|
|
3
|
+
## 2.0.1
|
4
|
+
|
5
|
+
### Resolved Issues
|
6
|
+
|
7
|
+
* \#288, \#278, \#252, \#247, \#275, \#290
|
8
|
+
Re-apply credentials when connection is lost with the server. (zarqman)
|
9
|
+
|
10
|
+
* mongoid/mongoid\#3790 Allow Session pool_timeout option. (Niels Ganser)
|
11
|
+
|
12
|
+
* \#297 Better retry on authentication. (Jonathan Hyman)
|
13
|
+
|
3
14
|
## 2.0.0
|
4
15
|
|
5
16
|
### API Changes (Backwards Incompatible)
|
data/README.md
CHANGED
@@ -1,4 +1,4 @@
|
|
1
|
-
Moped [![Build Status](https://secure.travis-ci.org/mongoid/moped.
|
1
|
+
Moped [![Build Status](https://secure.travis-ci.org/mongoid/moped.svg?branch=master)](http://travis-ci.org/mongoid/moped) [![Code Climate](https://codeclimate.com/github/mongoid/moped.svg)](https://codeclimate.com/github/mongoid/moped) [![Coverage Status](https://coveralls.io/repos/mongoid/moped/badge.png?branch=master)](https://coveralls.io/r/mongoid/moped?branch=master)
|
2
2
|
========
|
3
3
|
|
4
4
|
Moped is a MongoDB driver for Ruby, which exposes a simple, elegant, and fast
|
@@ -28,6 +28,7 @@ module Moped
|
|
28
28
|
login(database, username, password)
|
29
29
|
end
|
30
30
|
end
|
31
|
+
@original_credentials = credentials.dup
|
31
32
|
end
|
32
33
|
self
|
33
34
|
end
|
@@ -71,7 +72,17 @@ module Moped
|
|
71
72
|
self.write([ authenticate ])
|
72
73
|
document = self.read.documents.first
|
73
74
|
|
74
|
-
|
75
|
+
unless result["ok"] == 1
|
76
|
+
# See if we had connectivity issues so we can retry
|
77
|
+
e = Errors::PotentialReconfiguration.new(authenticate, document)
|
78
|
+
if e.reconfiguring_replica_set?
|
79
|
+
raise Errors::ReplicaSetReconfigured.new(e.command, e.details)
|
80
|
+
elsif e.connection_failure?
|
81
|
+
raise Errors::ConnectionFailure.new(e.inspect)
|
82
|
+
end
|
83
|
+
|
84
|
+
raise Errors::AuthenticationFailure.new(authenticate, document)
|
85
|
+
end
|
75
86
|
credentials[database] = [username, password]
|
76
87
|
end
|
77
88
|
|
data/lib/moped/cluster.rb
CHANGED
@@ -174,7 +174,13 @@ module Moped
|
|
174
174
|
seen = {}
|
175
175
|
# Set up a recursive lambda function for refreshing a node and it's peers.
|
176
176
|
refresh_node = ->(node) do
|
177
|
-
unless
|
177
|
+
unless node.address.resolved
|
178
|
+
begin
|
179
|
+
node.refresh
|
180
|
+
rescue Errors::ConnectionFailure
|
181
|
+
end
|
182
|
+
end
|
183
|
+
unless seen[node] || !node.address.resolved
|
178
184
|
seen[node] = true
|
179
185
|
# Add the node to the global list of known nodes.
|
180
186
|
seeds.push(node) unless seeds.include?(node)
|
@@ -264,11 +270,11 @@ module Moped
|
|
264
270
|
#
|
265
271
|
# @since 1.0.0
|
266
272
|
def with_secondary(&block)
|
267
|
-
available_nodes =
|
273
|
+
available_nodes = available_secondary_nodes
|
268
274
|
while node = available_nodes.shift
|
269
275
|
begin
|
270
276
|
return yield(node)
|
271
|
-
rescue Errors::ConnectionFailure => e
|
277
|
+
rescue Errors::ConnectionFailure, Errors::ReplicaSetReconfigured => e
|
272
278
|
next
|
273
279
|
end
|
274
280
|
end
|
@@ -277,6 +283,10 @@ module Moped
|
|
277
283
|
|
278
284
|
private
|
279
285
|
|
286
|
+
def available_secondary_nodes
|
287
|
+
nodes.select(&:secondary?).shuffle!
|
288
|
+
end
|
289
|
+
|
280
290
|
# Apply the credentials on all nodes
|
281
291
|
#
|
282
292
|
# @api private
|
@@ -365,8 +375,10 @@ module Moped
|
|
365
375
|
# @since 1.0.0
|
366
376
|
def refresh_peers(node, &block)
|
367
377
|
node.peers.each do |node|
|
368
|
-
|
369
|
-
|
378
|
+
if node.address.resolved
|
379
|
+
block.call(node) unless seeds.include?(node)
|
380
|
+
peers.push(node) unless peers.include?(node)
|
381
|
+
end
|
370
382
|
end
|
371
383
|
end
|
372
384
|
end
|
data/lib/moped/connection.rb
CHANGED
@@ -46,6 +46,7 @@ module Moped
|
|
46
46
|
#
|
47
47
|
# @since 1.0.0
|
48
48
|
def connect
|
49
|
+
credentials.clear
|
49
50
|
@sock = if !!options[:ssl]
|
50
51
|
Socket::SSL.connect(host, port, timeout)
|
51
52
|
else
|
@@ -74,7 +75,6 @@ module Moped
|
|
74
75
|
#
|
75
76
|
# @since 1.0.0
|
76
77
|
def disconnect
|
77
|
-
credentials.clear
|
78
78
|
@sock.close
|
79
79
|
rescue
|
80
80
|
ensure
|
@@ -217,7 +217,10 @@ module Moped
|
|
217
217
|
#
|
218
218
|
# @since 1.3.0
|
219
219
|
def with_connection
|
220
|
-
|
220
|
+
if @sock.nil? || !@sock.alive?
|
221
|
+
connect
|
222
|
+
apply_credentials(@original_credentials || {})
|
223
|
+
end
|
221
224
|
yield @sock
|
222
225
|
end
|
223
226
|
end
|
data/lib/moped/errors.rb
CHANGED
@@ -115,7 +115,7 @@ module Moped
|
|
115
115
|
NOT_MASTER = [ 13435, 13436, 10009 ]
|
116
116
|
|
117
117
|
# Error codes received around reconfiguration
|
118
|
-
CONNECTION_ERRORS_RECONFIGURATION = [ 15988, 10276, 11600, 9001, 13639, 10009 ]
|
118
|
+
CONNECTION_ERRORS_RECONFIGURATION = [ 15988, 10276, 11600, 9001, 13639, 10009, 11002 ]
|
119
119
|
|
120
120
|
# Replica set reconfigurations can be either in the form of an operation
|
121
121
|
# error with code 13435, or with an error message stating the server is
|
data/lib/moped/node.rb
CHANGED
@@ -137,7 +137,7 @@ module Moped
|
|
137
137
|
#
|
138
138
|
# @since 1.2.0
|
139
139
|
def disconnect
|
140
|
-
connection{ |conn| conn.disconnect }
|
140
|
+
connection{ |conn| conn.disconnect } if address.resolved
|
141
141
|
true
|
142
142
|
end
|
143
143
|
|
@@ -175,9 +175,9 @@ module Moped
|
|
175
175
|
|
176
176
|
begin
|
177
177
|
connection do |conn|
|
178
|
-
|
179
|
-
connect(conn) unless conn.connected?
|
178
|
+
connect(conn) unless conn.alive?
|
180
179
|
conn.apply_credentials(@credentials)
|
180
|
+
stack(:connection) << conn
|
181
181
|
yield(conn)
|
182
182
|
end
|
183
183
|
rescue Exception => e
|
data/lib/moped/session.rb
CHANGED
@@ -210,6 +210,11 @@ module Moped
|
|
210
210
|
# @since 2.0.0
|
211
211
|
option(:pool_size).allow(Optionable.any(Integer))
|
212
212
|
|
213
|
+
# Setup validation of allowed pool timeout options. (Any numeric)
|
214
|
+
#
|
215
|
+
# @since 2.0.0
|
216
|
+
option(:pool_timeout).allow(Optionable.any(Numeric))
|
217
|
+
|
213
218
|
# Setup validation of allowed retry interval options. (Any numeric)
|
214
219
|
#
|
215
220
|
# @since 2.0.0
|
data/lib/moped/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: moped
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.0.
|
4
|
+
version: 2.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Durran Jordan
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-10-16 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bson
|