moped 1.3.0 → 1.3.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.

data/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Overview
2
2
 
3
+ ## 1.3.1
4
+
5
+ ### Resolved Issues
6
+
7
+ * \#118 Give better error when invalid URI is provided. (Chris Winslett)
8
+
9
+ * \#116 Handle all cases of replica set step down or reconfiguring.
10
+ (Chris Winslett)
11
+
12
+ * Change the default retries to 20 and the retry interval to 0.25 seconds.
13
+ (Old was 30/1)
14
+
3
15
  ## 1.3.0
4
16
 
5
17
  ### New Features
data/lib/moped/cluster.rb CHANGED
@@ -103,9 +103,9 @@ module Moped
103
103
 
104
104
  @options = {
105
105
  down_interval: 30,
106
- max_retries: 30,
106
+ max_retries: 20,
107
107
  refresh_interval: 300,
108
- retry_interval: 1
108
+ retry_interval: 0.25
109
109
  }.merge(options)
110
110
  end
111
111
 
data/lib/moped/errors.rb CHANGED
@@ -11,6 +11,9 @@ module Moped
11
11
  # Raised when a database name is invalid.
12
12
  class InvalidDatabaseName < StandardError; end
13
13
 
14
+ # Raised when a Mongo URI is invalid.
15
+ class InvalidMongoURI < StandardError; end
16
+
14
17
  # Raised when providing an invalid string from an object id.
15
18
  class InvalidObjectId < StandardError
16
19
 
@@ -63,6 +63,35 @@ module Moped
63
63
  # @since 1.3.0
64
64
  def initialize(string)
65
65
  @match = string.match(URI)
66
+ invalid_uri!(string) unless @match
67
+ end
68
+
69
+ # Raise a human readable error when improper URI provided
70
+ #
71
+ # @example Raise error and provide guidance on invalid URI
72
+ # MongoUri.invalid!(uri)
73
+ #
74
+ # @param [ String ] Invalid string
75
+ #
76
+ # @since 1.3.1
77
+ def invalid_uri!(string)
78
+ msg = %{
79
+ The given connection string is invalid:
80
+ #{string.gsub(/[^:]+@/, '<password>@')}
81
+
82
+ MongoDB connection strings must be of the format:
83
+ mongodb://host:port/database
84
+
85
+ For authentication, include username and password before host:
86
+ mongodb://username:password@host:port/database
87
+
88
+ For Replica Sets, include multiple host:port entries:
89
+ mongodb://host:port,host2:port2/database
90
+
91
+ For options, use query string syntax with the option value:
92
+ mongodb://host:port/database?safe=true&max_retries=30&timeout=5
93
+ }
94
+ raise Errors::InvalidMongoURI, msg
66
95
  end
67
96
 
68
97
  # Get the options provided in the URI.
data/lib/moped/node.rb CHANGED
@@ -140,8 +140,9 @@ module Moped
140
140
  raise
141
141
  rescue Errors::OperationFailure => e
142
142
  # We might have a replica set change with:
143
- # "failed with error 10054: "not master"
144
- if e.details['code'] == 10054
143
+ # MongoDB uses 3 different error codes for "not master", [10054, 10056, 10058]
144
+ # thus it is easier to capture the "err"
145
+ if e.details["err"] == "not master"
145
146
  raise Errors::ReplicaSetReconfigured
146
147
  end
147
148
  raise
data/lib/moped/version.rb CHANGED
@@ -1,4 +1,4 @@
1
1
  # encoding: utf-8
2
2
  module Moped
3
- VERSION = "1.3.0"
3
+ VERSION = "1.3.1"
4
4
  end
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: 1.3.0
4
+ version: 1.3.1
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: 2012-11-18 00:00:00.000000000 Z
12
+ date: 2012-12-02 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: A MongoDB driver for Ruby.
15
15
  email:
@@ -89,7 +89,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
89
89
  version: '0'
90
90
  segments:
91
91
  - 0
92
- hash: 2772381747018055837
92
+ hash: 3571351846230510378
93
93
  required_rubygems_version: !ruby/object:Gem::Requirement
94
94
  none: false
95
95
  requirements:
@@ -98,7 +98,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
98
98
  version: '0'
99
99
  segments:
100
100
  - 0
101
- hash: 2772381747018055837
101
+ hash: 3571351846230510378
102
102
  requirements: []
103
103
  rubyforge_project:
104
104
  rubygems_version: 1.8.24