couchrest_changes 0.2.0 → 0.2.1
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/lib/couchrest/changes/observer.rb +21 -13
- data/lib/couchrest/changes/version.rb +1 -1
- metadata +2 -8
@@ -38,6 +38,12 @@ module CouchRest::Changes
|
|
38
38
|
end
|
39
39
|
end
|
40
40
|
|
41
|
+
#
|
42
|
+
# NOTE: the sequence stored in the variable @since is a different format
|
43
|
+
# depending on which flavor of couchdb is being used. For normal couchdb
|
44
|
+
# prior to version 2.0, the sequence is just a number. For bigcouch and
|
45
|
+
# new couchdb instances, the sequence is an array.
|
46
|
+
#
|
41
47
|
class Observer
|
42
48
|
|
43
49
|
attr_writer :logger
|
@@ -160,19 +166,20 @@ module CouchRest::Changes
|
|
160
166
|
debug "Looking up sequence here: #{filename}"
|
161
167
|
result = File.read(filename)
|
162
168
|
if result.empty?
|
163
|
-
debug "Found no sequence in the file."
|
169
|
+
debug "Found no sequence in the file #{filename}."
|
164
170
|
return 0
|
165
171
|
else
|
166
172
|
debug "Found sequence: #{result}"
|
167
|
-
return result
|
173
|
+
return result
|
168
174
|
end
|
169
175
|
rescue Errno::ENOENT => e
|
170
|
-
warn "No sequence file found. Starting from scratch"
|
176
|
+
warn "No sequence file found. Starting from scratch (#{filename})"
|
171
177
|
return 0
|
172
178
|
end
|
173
179
|
|
174
180
|
def store_seq(db_name, seq)
|
175
|
-
|
181
|
+
# seq might be a number or an array
|
182
|
+
File.write sequence_file_name(db_name), MultiJson.dump(seq)
|
176
183
|
end
|
177
184
|
|
178
185
|
def sequence_file_name(db_name)
|
@@ -182,7 +189,8 @@ module CouchRest::Changes
|
|
182
189
|
def retry_without_sequence?(result, last_hash)
|
183
190
|
if malformated_sequence?(result) || malformated_sequence?(last_hash)
|
184
191
|
@since = 0
|
185
|
-
info "Trying to start from scratch."
|
192
|
+
info "Trying to start from scratch (db #{@db_name})."
|
193
|
+
debug { {:result => result, :last_hash => last_hash}.inspect }
|
186
194
|
end
|
187
195
|
end
|
188
196
|
|
@@ -211,24 +219,24 @@ module CouchRest::Changes
|
|
211
219
|
Config.flags.include?('--run-once')
|
212
220
|
end
|
213
221
|
|
214
|
-
def info(
|
222
|
+
def info(*args, &block)
|
215
223
|
return unless log_attempt?
|
216
|
-
logger.info
|
224
|
+
logger.info *args, &block
|
217
225
|
end
|
218
226
|
|
219
|
-
def debug(
|
227
|
+
def debug(*args, &block)
|
220
228
|
return unless log_attempt?
|
221
|
-
logger.debug
|
229
|
+
logger.debug *args, &block
|
222
230
|
end
|
223
231
|
|
224
|
-
def warn(
|
232
|
+
def warn(*args, &block)
|
225
233
|
return unless log_attempt?
|
226
|
-
logger.warn
|
234
|
+
logger.warn *args, &block
|
227
235
|
end
|
228
236
|
|
229
|
-
def error(
|
237
|
+
def error(*args, &block)
|
230
238
|
return unless log_attempt?
|
231
|
-
logger.error
|
239
|
+
logger.error *args, &block
|
232
240
|
end
|
233
241
|
|
234
242
|
# let's not clutter the logs if couch is down for a longer time.
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: couchrest_changes
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.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: 2015-
|
12
|
+
date: 2015-04-01 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: couchrest
|
@@ -155,18 +155,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
155
155
|
- - ! '>='
|
156
156
|
- !ruby/object:Gem::Version
|
157
157
|
version: '0'
|
158
|
-
segments:
|
159
|
-
- 0
|
160
|
-
hash: 3909050601515988109
|
161
158
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
162
159
|
none: false
|
163
160
|
requirements:
|
164
161
|
- - ! '>='
|
165
162
|
- !ruby/object:Gem::Version
|
166
163
|
version: '0'
|
167
|
-
segments:
|
168
|
-
- 0
|
169
|
-
hash: 3909050601515988109
|
170
164
|
requirements: []
|
171
165
|
rubyforge_project:
|
172
166
|
rubygems_version: 1.8.23
|