mongo-oplog-backup 0.0.8 → 0.0.9

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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8fd77128ff3c7a9fea813efd8fdb04197c7cb42b
4
- data.tar.gz: 644387bdbdf649dca6527d7e1a0636043f1e3aee
3
+ metadata.gz: 1ee5f2e07aafef152cc9122c0857a8546159fb1e
4
+ data.tar.gz: 29c70641a560009a829822a0925c827ca9b24854
5
5
  SHA512:
6
- metadata.gz: 23665952e8feafd8ef03cdb792b59e07d067a516e1234f64c38884bcfa074563b9a53f0a84adac0e072b912d803b1434272fcf732b6628dfb3901f26ed28233b
7
- data.tar.gz: 66147160a921815228d5333621e2a082f18653f998014e84a75d2a122b9896cc30c9f9307f1a49fafaed1c517070953617157aae8e949809eee6a336d679a2f5
6
+ metadata.gz: da1308e0f5e15a7a3b89816cdea169bf60801f2adecb5d4ae8a14fcdb46a858aa1fb3ec455e9af73ba332af1f55932416859b9ba638dba5d51fe8bb3274727d4
7
+ data.tar.gz: 4728871d1ca7b05fec204ddb66c5a66918fc4a3e4c9cddc89c415764f03d074d4426cd0704a5c94f8abef244894bff5aede96f0c9f2e8d7fee9cd7e624a5c5a1
@@ -71,17 +71,26 @@ module MongoOplogBackup
71
71
  def run
72
72
  @status = Open3.popen3(*command) do |stdin, stdout, stderr, wait_thr|
73
73
  stdin.close_write
74
- until all_eof([stdout, stderr])
75
- read_available_data(stdout) do |data|
76
- @out_blocks.each do |block|
77
- block.call(data)
78
- end
79
- end
80
- read_available_data(stderr) do |data|
81
- @err_blocks.each do |block|
82
- block.call(data)
83
- end
74
+ # until all_eof([stdout, stderr])
75
+ still_open = [stdout, stderr]
76
+ until still_open.empty?
77
+ handles = IO.select(still_open, nil, nil, 0.001)
78
+
79
+ unless handles.nil?
80
+ read_available_data(stdout) do |data|
81
+ @out_blocks.each do |block|
82
+ block.call(data)
83
+ end
84
+ end if handles[0].include?(stdout)
85
+
86
+ read_available_data(stderr) do |data|
87
+ @err_blocks.each do |block|
88
+ block.call(data)
89
+ end
90
+ end if handles[0].include?(stderr)
84
91
  end
92
+
93
+ still_open.delete_if { |s| s.closed? }
85
94
  sleep 0.001
86
95
  end
87
96
 
@@ -111,14 +120,10 @@ module MongoOplogBackup
111
120
  BLOCK_SIZE = 1024
112
121
 
113
122
  def read_available_data(io, &block)
114
- if io.ready?
115
- data = io.read_nonblock(BLOCK_SIZE)
116
- block.call data
117
- end
118
- end
119
-
120
- def all_eof(files)
121
- files.find { |f| !f.eof }.nil?
123
+ data = io.read_nonblock(BLOCK_SIZE)
124
+ block.call data
125
+ rescue EOFError
126
+ io.close
122
127
  end
123
128
  end
124
129
  end
@@ -1,3 +1,3 @@
1
1
  module MongoOplogBackup
2
- VERSION = "0.0.8"
2
+ VERSION = "0.0.9"
3
3
  end
@@ -24,7 +24,7 @@ describe MongoOplogBackup::Command do
24
24
  it 'should log' do
25
25
  io = StringIO.new
26
26
  logger = Logger.new io
27
- MongoOplogBackup::Command.execute(['ruby', '-e', 'puts "BAR"; $stderr.puts "FOO"'], logger: logger)
27
+ MongoOplogBackup::Command.execute(['ruby', '-e', 'puts "BAR"; $stdout.flush; $stderr.puts "FOO"'], logger: logger)
28
28
  io.rewind
29
29
  log = io.read
30
30
  log.should =~ /D, \[.+\] DEBUG -- : BAR\nE, \[.+\] ERROR -- : FOO\n/
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: mongo-oplog-backup
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.0.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ralf Kistner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-05-09 00:00:00.000000000 Z
11
+ date: 2016-05-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: bson