Skip to content
This repository was archived by the owner on Dec 22, 2020. It is now read-only.

Commit e6b0b03

Browse files
committed
Merge pull request #76 from meteor/oplog-filter
Allow specifying an oplog filter
2 parents a3a8214 + 9af3d6f commit e6b0b03

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

lib/mosql/cli.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,11 @@ def parse_args
9898
opts.on("--unsafe", "Ignore rows that cause errors on insert") do
9999
@options[:unsafe] = true
100100
end
101+
102+
# eg, --oplog-filter '{"ns": {"$regex": "^somedb[0-9]*\\.collection$"}}'
103+
opts.on("--oplog-filter [filter]", "An additional JSON filter for the oplog query") do |filter|
104+
@options[:oplog_filter] = JSON.parse(filter)
105+
end
101106
end
102107

103108
optparse.parse!(@args)

lib/mosql/streamer.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@ def optail
170170
if tail_from.is_a? Time
171171
tail_from = tailer.most_recent_position(tail_from)
172172
end
173-
tailer.tail(:from => tail_from)
173+
tailer.tail(:from => tail_from, :filter => options[:oplog_filter])
174174
until @done
175175
tailer.stream(1000) do |op|
176176
handle_op(op)

0 commit comments

Comments
 (0)