moped 1.4.5 → 1.5.0
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 +28 -0
- data/lib/moped/cluster.rb +10 -1
- data/lib/moped/node.rb +20 -15
- data/lib/moped/protocol/reply.rb +1 -1
- data/lib/moped/query.rb +1 -1
- 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: c161ed1156380d43da8e438ce1c4777089e84e5a
|
4
|
+
data.tar.gz: 606d2329d6b50ec8a08d425b1094b0d572ec989a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 58f9af192a2de8b18aaa1e6ff2a7a5b5652a5db8c38624143c8fc057a02daf974d81cf053f6b963b70e99d54849c866ab0b82c02a5c9abd7949e11a842020d75
|
7
|
+
data.tar.gz: 0e012db8dfb2fa04c3ecbfb3dfa20c125f3691428a0937c29d15f9f7872f07d2277c9d867273ab1b899c73fba85a454bc7aa65db31197bad1e3ffbb304bc7a81
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,33 @@
|
|
1
1
|
# Overview
|
2
2
|
|
3
|
+
## 1.5.0
|
4
|
+
|
5
|
+
### New Features
|
6
|
+
|
7
|
+
* The session now has an additional configuration option, called `auto_discover`.
|
8
|
+
which defaults to `true`. Auto-discovery means that nodes that are not provided
|
9
|
+
explicitly to the session but are visible will become available for read/write
|
10
|
+
in the application. This behavior is the same as the existing behavior.
|
11
|
+
|
12
|
+
The change here is to be able to turn this off by setting `auto_discover: false`.
|
13
|
+
This will tell Moped to only send messages to nodes explicitly provided when
|
14
|
+
instantiating the session.
|
15
|
+
|
16
|
+
Example:
|
17
|
+
|
18
|
+
Moped::Session.new([ "127.0.0.1:27017" ], auto_discover: false)
|
19
|
+
|
20
|
+
* \#189 Moped now logs connection attempts during retries. (Jan Paul Posma)
|
21
|
+
|
22
|
+
## 1.4.6
|
23
|
+
|
24
|
+
### Resolved Issues
|
25
|
+
|
26
|
+
* \#192 Return the proper result after reauthentication attempts.
|
27
|
+
(Jonathan Hyman)
|
28
|
+
|
29
|
+
* \#191 Checking for "not authorized" in error messages. (Jonathan Hyman)
|
30
|
+
|
3
31
|
## 1.4.5
|
4
32
|
|
5
33
|
### Resolved Issues
|
data/lib/moped/cluster.rb
CHANGED
@@ -8,7 +8,7 @@ module Moped
|
|
8
8
|
# @attribute [r] seeds The seeds the cluster was initialized with.
|
9
9
|
attr_reader :options, :seeds
|
10
10
|
|
11
|
-
# Get the
|
11
|
+
# Get the credentials for the cluster.
|
12
12
|
#
|
13
13
|
# @example Get the authentication details.
|
14
14
|
# cluster.auth
|
@@ -216,6 +216,7 @@ module Moped
|
|
216
216
|
|
217
217
|
if retries > 0
|
218
218
|
# We couldn't find a primary node, so refresh the list and try again.
|
219
|
+
warning(" MOPED: Retrying connection to primary for replica set #{inspect}")
|
219
220
|
sleep(retry_interval)
|
220
221
|
refresh
|
221
222
|
with_primary(retries - 1, &block)
|
@@ -249,6 +250,7 @@ module Moped
|
|
249
250
|
begin
|
250
251
|
return yield node.apply_auth(auth)
|
251
252
|
rescue Errors::ConnectionFailure
|
253
|
+
warning(" MOPED: Connection failed to secondary node #{node.inspect}, trying next node.")
|
252
254
|
# That node's no good, so let's try the next one.
|
253
255
|
next
|
254
256
|
end
|
@@ -257,6 +259,7 @@ module Moped
|
|
257
259
|
if retries > 0
|
258
260
|
# We couldn't find a secondary or primary node, so refresh the list and
|
259
261
|
# try again.
|
262
|
+
warning(" MOPED: Could not connect to any node in replica set #{inspect}, refreshing list.")
|
260
263
|
sleep(retry_interval)
|
261
264
|
refresh
|
262
265
|
with_secondary(retries - 1, &block)
|
@@ -290,5 +293,11 @@ module Moped
|
|
290
293
|
@peers.push(node) unless peers.include?(node)
|
291
294
|
end
|
292
295
|
end
|
296
|
+
|
297
|
+
def warning(message)
|
298
|
+
if logger = Moped.logger
|
299
|
+
logger.warn(message)
|
300
|
+
end
|
301
|
+
end
|
293
302
|
end
|
294
303
|
end
|
data/lib/moped/node.rb
CHANGED
@@ -60,6 +60,18 @@ module Moped
|
|
60
60
|
self
|
61
61
|
end
|
62
62
|
|
63
|
+
# Is the cluster auto-discovering new nodes in the cluster?
|
64
|
+
#
|
65
|
+
# @example Is the cluster auto discovering?
|
66
|
+
# cluster.auto_discovering?
|
67
|
+
#
|
68
|
+
# @return [ true, false ] If the cluster is auto discovering.
|
69
|
+
#
|
70
|
+
# @since 2.0.0
|
71
|
+
def auto_discovering?
|
72
|
+
@auto_discovering ||= options[:auto_discover].nil? ? true : options[:auto_discover]
|
73
|
+
end
|
74
|
+
|
63
75
|
# Execute a command against a database.
|
64
76
|
#
|
65
77
|
# @example Execute a command.
|
@@ -82,7 +94,7 @@ module Moped
|
|
82
94
|
if reply.command_failure?
|
83
95
|
if reply.unauthorized? && auth.has_key?(database)
|
84
96
|
login(database, *auth[database])
|
85
|
-
command(database, cmd, options)
|
97
|
+
return command(database, cmd, options)
|
86
98
|
else
|
87
99
|
raise Errors::OperationFailure.new(operation, result)
|
88
100
|
end
|
@@ -365,7 +377,7 @@ module Moped
|
|
365
377
|
# connection. In this case we need to requthenticate and try again,
|
366
378
|
# otherwise we'll just raise the error to the user.
|
367
379
|
login(database, *auth[database])
|
368
|
-
query(database, collection, selector, options)
|
380
|
+
return query(database, collection, selector, options)
|
369
381
|
else
|
370
382
|
raise Errors::QueryFailure.new(operation, reply.documents.first)
|
371
383
|
end
|
@@ -480,15 +492,6 @@ module Moped
|
|
480
492
|
@auth ||= {}
|
481
493
|
end
|
482
494
|
|
483
|
-
def generate_peers(info)
|
484
|
-
peers = []
|
485
|
-
peers.push(info["primary"]) if info["primary"]
|
486
|
-
peers.concat(info["hosts"]) if info["hosts"]
|
487
|
-
peers.concat(info["passives"]) if info["passives"]
|
488
|
-
peers.concat(info["arbiters"]) if info["arbiters"]
|
489
|
-
@peers = peers.map { |peer| Node.new(peer, options) }.uniq
|
490
|
-
end
|
491
|
-
|
492
495
|
def login(database, username, password)
|
493
496
|
getnonce = Protocol::Command.new(database, getnonce: 1)
|
494
497
|
connection.write [getnonce]
|
@@ -514,10 +517,12 @@ module Moped
|
|
514
517
|
|
515
518
|
def generate_peers(info)
|
516
519
|
peers = []
|
517
|
-
|
518
|
-
|
519
|
-
|
520
|
-
|
520
|
+
if auto_discovering?
|
521
|
+
peers.push(info["primary"]) if info["primary"]
|
522
|
+
peers.concat(info["hosts"]) if info["hosts"]
|
523
|
+
peers.concat(info["passives"]) if info["passives"]
|
524
|
+
peers.concat(info["arbiters"]) if info["arbiters"]
|
525
|
+
end
|
521
526
|
@peers = peers.map{ |peer| discover(peer) }.uniq
|
522
527
|
end
|
523
528
|
|
data/lib/moped/protocol/reply.rb
CHANGED
@@ -93,7 +93,7 @@ module Moped
|
|
93
93
|
# @since 1.2.0
|
94
94
|
def query_failed?
|
95
95
|
result = documents[0]
|
96
|
-
flags.include?(:query_failure) || (result && result["$err"])
|
96
|
+
flags.include?(:query_failure) || (result && (result["err"] || result["errmsg"] || result["$err"]))
|
97
97
|
end
|
98
98
|
|
99
99
|
# Is the reply an error message that we are not authorized for the query
|
data/lib/moped/query.rb
CHANGED
data/lib/moped/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: moped
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.5.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bernerd Schaefer
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2013-
|
11
|
+
date: 2013-05-16 00:00:00.000000000 Z
|
12
12
|
dependencies: []
|
13
13
|
description: A MongoDB driver for Ruby.
|
14
14
|
email:
|