curate-indexer 0.1.2 → 0.2.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.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ecfbe4261639066afa2f5f7bfe07a454bd93eafd
|
4
|
+
data.tar.gz: 7e05eb98cf120fdb06b8c8e64796f033f35df13d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9a697810391125695cfa863c29ae5d2bf4cb9f61a1da7576211f3b0c5597551aa4b613ebd070fda1795eb7ea5e31de7e530b76e6c93a9551e82f3baf5485b6e7
|
7
|
+
data.tar.gz: edf309676d3f07e1332b9328cd3a04330387dedfcf66318f545a234a44d05f8f31c938dcbe0ce0e9080b23878d0f70c7fd017e0215b04526341093706419025e
|
@@ -25,7 +25,7 @@ module Curate
|
|
25
25
|
end
|
26
26
|
|
27
27
|
# @api public
|
28
|
-
# @param
|
28
|
+
# @param document [Curate::Indexer::Documents::IndexDocument]
|
29
29
|
# @yield Curate::Indexer::Documents::IndexDocument
|
30
30
|
def self.each_child_document_of(*, &_block)
|
31
31
|
raise NotImplementedError
|
@@ -29,10 +29,10 @@ module Curate
|
|
29
29
|
end
|
30
30
|
|
31
31
|
# @api public
|
32
|
-
# @param
|
32
|
+
# @param document [Curate::Indexer::Documents::IndexDocument]
|
33
33
|
# @yield Curate::Indexer::Documents::IndexDocument
|
34
|
-
def self.each_child_document_of(
|
35
|
-
Index.each_child_document_of(
|
34
|
+
def self.each_child_document_of(document, &block)
|
35
|
+
Index.each_child_document_of(document, &block)
|
36
36
|
end
|
37
37
|
|
38
38
|
# @api public
|
data/lib/curate/indexer/index.rb
CHANGED
@@ -17,8 +17,8 @@ module Curate
|
|
17
17
|
Storage.find(pid)
|
18
18
|
end
|
19
19
|
|
20
|
-
def self.each_child_document_of(
|
21
|
-
Storage.find_children_of_pid(pid).each(&block)
|
20
|
+
def self.each_child_document_of(document, &block)
|
21
|
+
Storage.find_children_of_pid(document.pid).each(&block)
|
22
22
|
end
|
23
23
|
|
24
24
|
def self.write_document(attributes = {})
|
@@ -24,12 +24,12 @@ module Curate
|
|
24
24
|
attr_reader :pid, :time_to_live, :queue, :adapter
|
25
25
|
|
26
26
|
def call
|
27
|
-
enqueue(
|
28
|
-
|
29
|
-
while
|
30
|
-
process_a_document(
|
31
|
-
adapter.each_child_document_of(
|
32
|
-
|
27
|
+
enqueue(initial_index_document, time_to_live)
|
28
|
+
processing_document = dequeue
|
29
|
+
while processing_document
|
30
|
+
process_a_document(processing_document)
|
31
|
+
adapter.each_child_document_of(processing_document) { |child| enqueue(child, processing_document.time_to_live - 1) }
|
32
|
+
processing_document = dequeue
|
33
33
|
end
|
34
34
|
self
|
35
35
|
end
|
@@ -38,13 +38,25 @@ module Curate
|
|
38
38
|
|
39
39
|
attr_writer :document
|
40
40
|
|
41
|
+
def initial_index_document
|
42
|
+
adapter.find_index_document_by(pid)
|
43
|
+
end
|
44
|
+
|
41
45
|
extend Forwardable
|
42
46
|
def_delegator :queue, :shift, :dequeue
|
43
47
|
|
44
|
-
|
48
|
+
require 'delegate'
|
49
|
+
# A small object to help track time to live concerns
|
50
|
+
class ProcessingDocument < SimpleDelegator
|
51
|
+
def initialize(document, time_to_live)
|
52
|
+
@time_to_live = time_to_live
|
53
|
+
super(document)
|
54
|
+
end
|
55
|
+
attr_reader :time_to_live
|
56
|
+
end
|
45
57
|
private_constant :ProcessingDocument
|
46
|
-
def enqueue(
|
47
|
-
queue.push(ProcessingDocument.new(
|
58
|
+
def enqueue(document, time_to_live)
|
59
|
+
queue.push(ProcessingDocument.new(document, time_to_live))
|
48
60
|
end
|
49
61
|
|
50
62
|
def process_a_document(index_document)
|