moped 2.0.0.beta → 2.0.0.beta2
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 +10 -0
- data/lib/moped.rb +1 -0
- data/lib/moped/address.rb +13 -4
- data/lib/moped/cluster.rb +1 -0
- data/lib/moped/cursor.rb +1 -0
- data/lib/moped/instrumentable.rb +1 -6
- data/lib/moped/instrumentable/log.rb +23 -29
- data/lib/moped/node.rb +1 -1
- data/lib/moped/query.rb +9 -11
- 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: d09eab93cd0182d6a05493df401ab183e83e3e2c
|
4
|
+
data.tar.gz: ec4275fe3a9c9b7e8e78832f879088f39518895b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: cdb92718589cc2fd38d8f9297dfc4d898cf9aa3fce14d19bd85b00932e5437909c3ba99f508086b4db963bd11e21d575a0b16e56d818e7c103cc643a110ed591
|
7
|
+
data.tar.gz: 7ea98d6a337de3f7b67f48a1ab3a1058b5774d016c5fab87dbd92464d5691f3571db06155c64bec7c73eb6338608f71d06f4b5bf44690ff6f8f3ba3776753c0e
|
data/CHANGELOG.md
CHANGED
@@ -8,6 +8,12 @@
|
|
8
8
|
|
9
9
|
### API Changes (Backwards Incompatible)
|
10
10
|
|
11
|
+
* Query.cursor will return a Enumerable instead of a Enumerator. (Arthur Neves)
|
12
|
+
|
13
|
+
* Moped's BSON implementation has been removed in favor of the 10gen
|
14
|
+
bson gem 2.0 and higher. All `Moped::BSON` references should be changed
|
15
|
+
to just `BSON`.
|
16
|
+
|
11
17
|
* \#190 Connection retries are now logged. (Jan Paul Posma)
|
12
18
|
|
13
19
|
* \#133 Moped now supports the new read preferences that the core drivers
|
@@ -42,6 +48,10 @@
|
|
42
48
|
|
43
49
|
The `:safe` option is no longer valid and will be ignored.
|
44
50
|
|
51
|
+
### Resolved Issues
|
52
|
+
|
53
|
+
* \#210 Moped no longer attempts to refresh arbiters as they cannot be queried.
|
54
|
+
|
45
55
|
## 1.5.1
|
46
56
|
|
47
57
|
### Resolved Issues
|
data/lib/moped.rb
CHANGED
data/lib/moped/address.rb
CHANGED
@@ -26,10 +26,11 @@ module Moped
|
|
26
26
|
# @param [ String ] address The host:port pair as a string.
|
27
27
|
#
|
28
28
|
# @since 2.0.0
|
29
|
-
def initialize(address)
|
29
|
+
def initialize(address, timeout)
|
30
30
|
@original = address
|
31
31
|
@host, port = address.split(":")
|
32
32
|
@port = (port || 27017).to_i
|
33
|
+
@timeout = timeout
|
33
34
|
end
|
34
35
|
|
35
36
|
# Resolve the address for the provided node. If the address cannot be
|
@@ -45,10 +46,18 @@ module Moped
|
|
45
46
|
# @since 2.0.0
|
46
47
|
def resolve(node)
|
47
48
|
begin
|
48
|
-
@
|
49
|
+
Timeout::timeout(@timeout) do
|
50
|
+
Resolv.each_address(host) do |ip|
|
51
|
+
if ip =~ Resolv::IPv4::Regex
|
52
|
+
@ip ||= ip
|
53
|
+
break
|
54
|
+
end
|
55
|
+
end
|
56
|
+
raise Resolv::ResolvError unless @ip
|
57
|
+
end
|
49
58
|
@resolved ||= "#{ip}:#{port}"
|
50
|
-
rescue
|
51
|
-
|
59
|
+
rescue Timeout::Error, Resolv::ResolvError
|
60
|
+
Loggable.warn(" MOPED:", "Could not resolve IP for: #{original}", "n/a")
|
52
61
|
node.down! and false
|
53
62
|
end
|
54
63
|
end
|
data/lib/moped/cluster.rb
CHANGED
data/lib/moped/cursor.rb
CHANGED
data/lib/moped/instrumentable.rb
CHANGED
@@ -8,12 +8,7 @@ module Moped
|
|
8
8
|
# The name of the topic of operations for Moped.
|
9
9
|
#
|
10
10
|
# @since 2.0.0
|
11
|
-
TOPIC = "moped
|
12
|
-
|
13
|
-
# Topic for warning instrumentation.
|
14
|
-
#
|
15
|
-
# @since 2.0.0
|
16
|
-
WARN = "moped.warn"
|
11
|
+
TOPIC = "query.moped"
|
17
12
|
|
18
13
|
# @!attribute instrumenter
|
19
14
|
# @return [ Object ] The instrumenter
|
@@ -6,36 +6,30 @@ module Moped
|
|
6
6
|
# notifications.
|
7
7
|
#
|
8
8
|
# @since 2.0.0
|
9
|
-
|
9
|
+
module Log
|
10
|
+
extend self
|
10
11
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
runtime = ("%.4fms" % (1000 * (Time.now.to_f - started.to_f)))
|
33
|
-
if name == TOPIC
|
34
|
-
Moped::Loggable.log_operations(payload[:prefix], payload[:ops], runtime)
|
35
|
-
else
|
36
|
-
Moped::Loggable.debug(payload[:prefix], payload.reject { |k,v| k == :prefix }, runtime)
|
37
|
-
end
|
38
|
-
end
|
12
|
+
# Instrument the log payload.
|
13
|
+
#
|
14
|
+
# @example Instrument the log payload.
|
15
|
+
# Log.instrument("moped.ops", {})
|
16
|
+
#
|
17
|
+
# @param [ String ] name The name of the logging type.
|
18
|
+
# @param [ Hash ] payload The log payload.
|
19
|
+
#
|
20
|
+
# @return [ Object ] The result of the yield.
|
21
|
+
#
|
22
|
+
# @since 2.0.0
|
23
|
+
def instrument(name, payload = {})
|
24
|
+
started = Time.new
|
25
|
+
begin
|
26
|
+
yield if block_given?
|
27
|
+
rescue Exception => e
|
28
|
+
payload[:exception] = [ e.class.name, e.message ]
|
29
|
+
raise e
|
30
|
+
ensure
|
31
|
+
runtime = ("%.4fms" % (1000 * (Time.now.to_f - started.to_f)))
|
32
|
+
Moped::Loggable.log_operations(payload[:prefix], payload[:ops], runtime)
|
39
33
|
end
|
40
34
|
end
|
41
35
|
end
|
data/lib/moped/node.rb
CHANGED
@@ -253,7 +253,6 @@ module Moped
|
|
253
253
|
#
|
254
254
|
# @since 1.0.0
|
255
255
|
def initialize(address, options = {})
|
256
|
-
@address = Address.new(address)
|
257
256
|
@options = options
|
258
257
|
@down_at = nil
|
259
258
|
@refreshed_at = nil
|
@@ -261,6 +260,7 @@ module Moped
|
|
261
260
|
@primary = nil
|
262
261
|
@secondary = nil
|
263
262
|
@instrumenter = options[:instrumenter] || Instrumentable::Log
|
263
|
+
@address = Address.new(address, timeout)
|
264
264
|
@address.resolve(self)
|
265
265
|
end
|
266
266
|
|
data/lib/moped/query.rb
CHANGED
@@ -13,7 +13,7 @@ module Moped
|
|
13
13
|
# people.find.skip(2).update(name: "John")
|
14
14
|
# people.find.skip(2).first # => { id: 3, name: "John" }
|
15
15
|
#
|
16
|
-
# people.find(name: nil).update_all(name: "Unknown")
|
16
|
+
# people.find(name: nil).update_all("$set" => { name: "Unknown" })
|
17
17
|
# people.find.one # => { id: 5, name: "Unknown" }
|
18
18
|
# people.find.first # => { id: 5, name: "Unknown" }
|
19
19
|
# people.find.select(name: 0).first # => { id: 5 }
|
@@ -68,20 +68,18 @@ module Moped
|
|
68
68
|
# #...
|
69
69
|
# end
|
70
70
|
#
|
71
|
-
# @return [
|
71
|
+
# @return [ Enumerable ]
|
72
72
|
#
|
73
73
|
# @since 1.0.0
|
74
74
|
#
|
75
75
|
# @yieldparam [ Hash ] document each matching document
|
76
|
-
def each
|
77
|
-
cursor
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
enum
|
76
|
+
def each(*args, &blk)
|
77
|
+
cursor.each(*args, &blk)
|
78
|
+
end
|
79
|
+
|
80
|
+
def cursor
|
81
|
+
Cursor.new(session, operation)
|
83
82
|
end
|
84
|
-
alias :cursor :each
|
85
83
|
|
86
84
|
# Explain the current query.
|
87
85
|
#
|
@@ -393,7 +391,7 @@ module Moped
|
|
393
391
|
# Update multiple documents matching the query's selector.
|
394
392
|
#
|
395
393
|
# @example Update multiple documents.
|
396
|
-
# db[:people].find(name: "John").update_all(name: "Mary")
|
394
|
+
# db[:people].find(name: "John").update_all("$set" => { name: "Mary" })
|
397
395
|
#
|
398
396
|
# @param [ Hash ] change The changes to make to the documents
|
399
397
|
#
|
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.0.
|
4
|
+
version: 2.0.0.beta2
|
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: 2013-
|
12
|
+
date: 2013-10-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bson
|