mongoriver 0.2.0 → 0.3.0
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/bin/watch-oplog +2 -2
- data/lib/mongoriver/abstract_persistent_tailer.rb +3 -5
- data/lib/mongoriver/stream.rb +3 -3
- data/lib/mongoriver/tailer.rb +14 -6
- data/lib/mongoriver/version.rb +1 -1
- metadata +2 -2
data/bin/watch-oplog
CHANGED
@@ -25,7 +25,7 @@ module Mongoriver
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def main
|
28
|
-
options = {:host => nil, :port => nil, :type => :direct, :optime =>
|
28
|
+
options = {:host => nil, :port => nil, :type => :direct, :optime => nil, :pause => true, :verbose => 0}
|
29
29
|
optparse = OptionParser.new do |opts|
|
30
30
|
opts.banner = "Usage: #{$0} [options]"
|
31
31
|
|
@@ -77,7 +77,7 @@ def main
|
|
77
77
|
end
|
78
78
|
end
|
79
79
|
|
80
|
-
stream.run_forever
|
80
|
+
stream.run_forever(options[:optime])
|
81
81
|
return 0
|
82
82
|
end
|
83
83
|
|
data/lib/mongoriver/stream.rb
CHANGED
@@ -23,9 +23,9 @@ module Mongoriver
|
|
23
23
|
|
24
24
|
def run_forever(starting_timestamp=nil)
|
25
25
|
if starting_timestamp
|
26
|
-
@tailer.
|
26
|
+
@tailer.tail(:from => optime_from_ts(starting_timestamp))
|
27
27
|
else
|
28
|
-
@tailer.
|
28
|
+
@tailer.tail
|
29
29
|
end
|
30
30
|
|
31
31
|
until @stop
|
@@ -166,4 +166,4 @@ module Mongoriver
|
|
166
166
|
trigger(:create_collection, db_name, collection_name, options)
|
167
167
|
end
|
168
168
|
end
|
169
|
-
end
|
169
|
+
end
|
data/lib/mongoriver/tailer.rb
CHANGED
@@ -67,23 +67,31 @@ module Mongoriver
|
|
67
67
|
@upstream_conn.db('local').collection(oplog)
|
68
68
|
end
|
69
69
|
|
70
|
-
def
|
70
|
+
def tail(opts = {})
|
71
71
|
raise "Already tailing the oplog!" if @cursor
|
72
72
|
|
73
|
-
|
74
|
-
|
73
|
+
query = opts[:filter] || {}
|
74
|
+
if ts = opts[:from]
|
75
|
+
# Maybe if ts is old enough, just start from the beginning?
|
76
|
+
query['ts'] = { '$gte' => ts }
|
77
|
+
end
|
75
78
|
|
76
79
|
oplog_collection.find(query, :timeout => false) do |oplog|
|
77
80
|
oplog.add_option(Mongo::Constants::OP_QUERY_TAILABLE)
|
78
|
-
oplog.add_option(Mongo::Constants::OP_QUERY_OPLOG_REPLAY)
|
79
|
-
|
81
|
+
oplog.add_option(Mongo::Constants::OP_QUERY_OPLOG_REPLAY) if query['ts']
|
80
82
|
oplog.add_option(Mongo::Constants::OP_QUERY_AWAIT_DATA) unless opts[:dont_wait]
|
81
83
|
|
82
|
-
log.info("Starting oplog stream from #{ts}")
|
84
|
+
log.info("Starting oplog stream from #{ts || 'start'}")
|
83
85
|
@cursor = oplog
|
84
86
|
end
|
85
87
|
end
|
86
88
|
|
89
|
+
# Deprecated: use #tail(:from => ts, ...) instead
|
90
|
+
def tail_from(ts, opts={})
|
91
|
+
opts.merge(:from => ts)
|
92
|
+
tail(opts)
|
93
|
+
end
|
94
|
+
|
87
95
|
def stream(limit=nil)
|
88
96
|
count = 0
|
89
97
|
while !@stop && @cursor.has_next?
|
data/lib/mongoriver/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: mongoriver
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.3.0
|
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-
|
12
|
+
date: 2013-06-07 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: mongo
|