ts-resque-delta 0.0.6 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- data/README.markdown +47 -22
- data/features/support/env.rb +0 -3
- data/features/thinking_sphinx/db/migrations/create_delayed_betas.rb +1 -14
- data/lib/thinking_sphinx/deltas/resque_delta.rb +19 -4
- data/lib/thinking_sphinx/deltas/resque_delta/delta_job.rb +10 -0
- data/lib/thinking_sphinx/deltas/resque_delta/tasks.rb +72 -14
- data/lib/thinking_sphinx/deltas/resque_delta/version.rb +1 -1
- data/spec/spec_helper.rb +0 -1
- data/spec/thinking_sphinx/deltas/resque_delta/delta_job_spec.rb +40 -9
- data/spec/thinking_sphinx/deltas/resque_delta/flag_as_deleted_job_spec.rb +5 -5
- data/spec/thinking_sphinx/deltas/resque_delta_spec.rb +44 -19
- data/ts-resque-delta.gemspec +6 -1
- metadata +81 -8
data/README.markdown
CHANGED
@@ -1,57 +1,82 @@
|
|
1
1
|
Delayed Deltas for Thinking Sphinx (with Resque)
|
2
2
|
================================================
|
3
|
-
|
4
|
-
|
3
|
+
**This code is HEAVILY borrowed from
|
4
|
+
[ts-delayed-delta](https://github.com/freelancing-god/ts-delayed-delta).**
|
5
5
|
|
6
6
|
Installation
|
7
7
|
------------
|
8
|
-
|
9
|
-
|
8
|
+
This gem depends on the following gems: _thinking-sphinx_, _resque_, and
|
9
|
+
_resque-lock-timeout_.
|
10
10
|
|
11
11
|
gem install ts-resque-delta
|
12
12
|
|
13
|
-
|
13
|
+
Add _ts-resque-delta_ to your **Gemfile** file, with the rest of your gem
|
14
|
+
dependencies:
|
14
15
|
|
15
|
-
gem 'ts-resque-delta', '
|
16
|
+
gem 'ts-resque-delta', '1.0.0',
|
17
|
+
:require => 'thinking_sphinx/deltas/resque_delta'
|
16
18
|
|
17
|
-
And add the following line to
|
19
|
+
And add the following line to your **Rakefile**:
|
18
20
|
|
19
21
|
require 'thinking_sphinx/deltas/resque_delta/tasks'
|
20
22
|
|
21
|
-
|
23
|
+
Add the delta property to each `define_index` block:
|
22
24
|
|
23
25
|
define_index do
|
24
26
|
# ...
|
25
27
|
set_property :delta => ThinkingSphinx::Deltas::ResqueDelta
|
26
28
|
end
|
27
29
|
|
28
|
-
If you've never used delta indexes before, you'll want to add the boolean
|
30
|
+
If you've never used delta indexes before, you'll want to add the boolean
|
31
|
+
column named `:delta` to each model's table (note, you must set the `:default`
|
32
|
+
value to `true`):
|
29
33
|
|
30
34
|
def self.up
|
31
|
-
add_column :
|
35
|
+
add_column :foos, :delta, :boolean, :default => true, :null => false
|
36
|
+
end
|
37
|
+
|
38
|
+
Also, I highly recommend adding a MySQL index to the table of any model using
|
39
|
+
delta indexes. The Sphinx indexer uses `WHERE table.delta = 1` whenever the
|
40
|
+
delta indexer runs and `... = 0` whenever the normal indexer runs. Having the
|
41
|
+
MySQL index on the delta column will generally be a win:
|
42
|
+
|
43
|
+
def self.up
|
44
|
+
# ...
|
45
|
+
add_index :foos, :delta
|
32
46
|
end
|
33
47
|
|
34
48
|
Usage
|
35
49
|
-----
|
50
|
+
Once you've got it all set up, all you need to do is make sure that the Resque
|
51
|
+
worker is running. You can do this by specifying the `:ts_delta` queue when
|
52
|
+
running Resque:
|
36
53
|
|
37
|
-
|
54
|
+
QUEUE=ts_delta,other_queues rake resque:work
|
38
55
|
|
39
|
-
|
56
|
+
Additionally, ts-resque-delta will wrap thinking-sphinx's
|
57
|
+
`thinking_sphinx:index` and `thinking_sphinx:reindex` tasks with
|
58
|
+
`thinking_sphinx:lock_deltas` and `thinking_sphinx:unlock_deltas`. This will
|
59
|
+
prevent the delta indexer from running at the same time as the main indexer.
|
40
60
|
|
41
|
-
|
61
|
+
Finally, ts-resque-delta also provides a rake task called
|
62
|
+
`thinking_sphinx:smart_index` (or `ts:si` for short). This task, instead of
|
63
|
+
locking all the delta indexes at once while the main indexer runs, will lock
|
64
|
+
each delta index independently and sequentially. Thay way, your delta indexer
|
65
|
+
can run while the main indexer is processing large core indexes.
|
42
66
|
|
43
|
-
|
67
|
+
Contributors (for ts-delayed-delta)
|
68
|
+
-----------------------------------
|
69
|
+
* [Aaron Gibralter](https://github.com/agibralter)
|
70
|
+
* [Ryan Schlesinger](https://github.com/ryansch) (Locking/`smart_index`)
|
44
71
|
|
45
72
|
Original Contributors (for ts-delayed-delta)
|
46
73
|
--------------------------------------------
|
47
|
-
|
48
|
-
* [
|
49
|
-
* [
|
50
|
-
* [
|
51
|
-
* [
|
52
|
-
* [Alexander Simonov](http://simonov.me/) (Explicit table definition)
|
74
|
+
* [Pat Allan](https://github.com/freelancing-god)
|
75
|
+
* [Ryan Schlesinger](https://github.com/ryansch) (Allowing installs as a plugin)
|
76
|
+
* [Maximilian Schulz](https://max.jungeelite.de) (Ensuring compatibility with Bundler)
|
77
|
+
* [Edgars Beigarts](https://github.com/ebeigarts) (Adding intelligent description for tasks)
|
78
|
+
* [Alexander Simonov](https://simonov.me/) (Explicit table definition)
|
53
79
|
|
54
80
|
Copyright
|
55
81
|
---------
|
56
|
-
|
57
|
-
Copyright (c) 2010 Aaron Gibralter, and released under an MIT Licence.
|
82
|
+
Copyright (c) 2011 Aaron Gibralter, and released under an MIT Licence.
|
data/features/support/env.rb
CHANGED
@@ -1,4 +1,3 @@
|
|
1
|
-
require 'rubygems'
|
2
1
|
require 'cucumber'
|
3
2
|
require 'spec/expectations'
|
4
3
|
require 'fileutils'
|
@@ -11,8 +10,6 @@ $:.unshift(File.dirname(__FILE__))
|
|
11
10
|
|
12
11
|
require 'cucumber/thinking_sphinx/internal_world'
|
13
12
|
|
14
|
-
Time.zone_default = Time.__send__(:get_zone, 'Melbourne')
|
15
|
-
ActiveRecord::Base.time_zone_aware_attributes = true
|
16
13
|
ActiveRecord::Base.default_timezone = :utc
|
17
14
|
|
18
15
|
world = Cucumber::ThinkingSphinx::InternalWorld.new
|
@@ -1,17 +1,4 @@
|
|
1
|
-
ActiveRecord::Base.connection.create_table :
|
1
|
+
ActiveRecord::Base.connection.create_table :delayed_beta, :force => true do |t|
|
2
2
|
t.column :name, :string, :null => false
|
3
3
|
t.column :delta, :boolean, :null => false, :default => false
|
4
4
|
end
|
5
|
-
|
6
|
-
ActiveRecord::Base.connection.create_table :delayed_jobs, :force => true do |t|
|
7
|
-
t.column :priority, :integer, :default => 0
|
8
|
-
t.column :attempts, :integer, :default => 0
|
9
|
-
t.column :handler, :text
|
10
|
-
t.column :last_error, :string
|
11
|
-
t.column :run_at, :datetime
|
12
|
-
t.column :locked_at, :datetime
|
13
|
-
t.column :failed_at, :datetime
|
14
|
-
t.column :locked_by, :string
|
15
|
-
t.column :created_at, :datetime
|
16
|
-
t.column :updated_at, :datetime
|
17
|
-
end
|
@@ -25,6 +25,18 @@ class ThinkingSphinx::Deltas::ResqueDelta < ThinkingSphinx::Deltas::DefaultDelta
|
|
25
25
|
end
|
26
26
|
end
|
27
27
|
|
28
|
+
def self.lock(index_name)
|
29
|
+
Resque.redis.set("ts-delta:index:#{index_name}:locked", 'true')
|
30
|
+
end
|
31
|
+
|
32
|
+
def self.unlock(index_name)
|
33
|
+
Resque.redis.del("ts-delta:index:#{index_name}:locked")
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.locked?(index_name)
|
37
|
+
Resque.redis.get("ts-delta:index:#{index_name}:locked") == 'true'
|
38
|
+
end
|
39
|
+
|
28
40
|
# Adds a job to the queue for processing the given model's delta index. A job
|
29
41
|
# for hiding the instance in the core index is also created, if an instance is
|
30
42
|
# provided.
|
@@ -41,10 +53,13 @@ class ThinkingSphinx::Deltas::ResqueDelta < ThinkingSphinx::Deltas::DefaultDelta
|
|
41
53
|
#
|
42
54
|
def index(model, instance = nil)
|
43
55
|
return true if skip?(instance)
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
56
|
+
model.delta_index_names.each do |delta|
|
57
|
+
next if self.class.locked?(delta)
|
58
|
+
Resque.enqueue(
|
59
|
+
ThinkingSphinx::Deltas::ResqueDelta::DeltaJob,
|
60
|
+
[delta]
|
61
|
+
)
|
62
|
+
end
|
48
63
|
if instance
|
49
64
|
Resque.enqueue(
|
50
65
|
ThinkingSphinx::Deltas::ResqueDelta::FlagAsDeletedJob,
|
@@ -14,6 +14,8 @@ class ThinkingSphinx::Deltas::ResqueDelta::DeltaJob
|
|
14
14
|
# @param [String] index the name of the Sphinx index
|
15
15
|
#
|
16
16
|
def self.perform(indexes)
|
17
|
+
return if skip?(indexes)
|
18
|
+
|
17
19
|
config = ThinkingSphinx::Configuration.instance
|
18
20
|
output = `#{config.bin_path}#{config.indexer_binary_name} --config #{config.config_file} --rotate #{indexes.join(' ')}`
|
19
21
|
puts output unless ThinkingSphinx.suppress_delta_output?
|
@@ -51,4 +53,12 @@ class ThinkingSphinx::Deltas::ResqueDelta::DeltaJob
|
|
51
53
|
Resque.redis.lrem("queue:#{@queue}", 0, redis_job_value)
|
52
54
|
yield
|
53
55
|
end
|
56
|
+
|
57
|
+
protected
|
58
|
+
|
59
|
+
def self.skip?(indexes)
|
60
|
+
indexes.any? do |index|
|
61
|
+
ThinkingSphinx::Deltas::ResqueDelta.locked?(index)
|
62
|
+
end
|
63
|
+
end
|
54
64
|
end
|
@@ -1,22 +1,80 @@
|
|
1
|
+
require 'thinking_sphinx/deltas/resque_delta'
|
2
|
+
|
1
3
|
namespace :thinking_sphinx do
|
2
|
-
|
3
|
-
|
4
|
+
|
5
|
+
# Return a list of index prefixes (i.e. without "_core"/"_delta").
|
6
|
+
def sphinx_indexes
|
7
|
+
unless @sphinx_indexes
|
8
|
+
@ts_config ||= ThinkingSphinx::Configuration.instance
|
9
|
+
@ts_config.generate
|
10
|
+
@sphinx_indexes = @ts_config.configuration.indexes.collect { |i| i.name }
|
11
|
+
# The collected indexes look like:
|
12
|
+
# ["foo_core", "foo_delta", "foo", "bar_core", "bar_delta", "bar"]
|
13
|
+
@sphinx_indexes.reject! { |i| i =~ /_(core|delta)$/}
|
14
|
+
# Now we have:
|
15
|
+
# ["foo", "bar"]
|
16
|
+
end
|
17
|
+
@sphinx_indexes
|
18
|
+
end
|
19
|
+
|
20
|
+
def lock_delta(index_name)
|
21
|
+
ThinkingSphinx::Deltas::ResqueDelta.lock("#{index_name}_delta")
|
22
|
+
end
|
23
|
+
|
24
|
+
def unlock_delta(index_name)
|
25
|
+
ThinkingSphinx::Deltas::ResqueDelta.unlock("#{index_name}_delta")
|
26
|
+
end
|
27
|
+
|
28
|
+
desc 'Lock all delta indexes (Resque will not run indexer or place new jobs on the :ts_delta queue).'
|
29
|
+
task :lock_deltas do
|
30
|
+
sphinx_indexes.each { |index_name| lock_delta(index_name) }
|
31
|
+
end
|
32
|
+
|
33
|
+
desc 'Unlock all delta indexes.'
|
34
|
+
task :unlock_deltas do
|
35
|
+
sphinx_indexes.each { |index_name| unlock_delta(index_name) }
|
4
36
|
end
|
5
37
|
|
6
|
-
desc
|
7
|
-
task :
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
38
|
+
desc 'Like `rake thinking_sphinx:index`, but locks one index at a time.'
|
39
|
+
task :smart_index => :app_env do
|
40
|
+
# Load config like ts:in.
|
41
|
+
@ts_config = ThinkingSphinx::Configuration.instance
|
42
|
+
unless ENV['INDEX_ONLY'] == 'true'
|
43
|
+
puts "Generating Configuration to #{@ts_config.config_file}"
|
44
|
+
@ts_config.build
|
45
|
+
end
|
46
|
+
FileUtils.mkdir_p(@ts_config.searchd_file_path)
|
47
|
+
|
48
|
+
# Index each core, one at a time. Wrap with delta locking logic.
|
49
|
+
sphinx_indexes.each do |index_name|
|
50
|
+
lock_delta(index_name)
|
51
|
+
@ts_config.controller.index("#{index_name}_core", :verbose => true)
|
52
|
+
ret = $?
|
53
|
+
unlock_delta(index_name)
|
54
|
+
exit(-1) if ret.to_i != 0
|
55
|
+
Resque.enqueue(
|
56
|
+
ThinkingSphinx::Deltas::ResqueDelta::DeltaJob,
|
57
|
+
["#{index_name}_delta"]
|
58
|
+
)
|
59
|
+
end
|
16
60
|
end
|
17
61
|
end
|
18
62
|
|
19
63
|
namespace :ts do
|
20
|
-
|
21
|
-
|
64
|
+
|
65
|
+
desc 'Like `rake thinking_sphinx:index`, but locks one index at a time.'
|
66
|
+
task :si => 'thinking_sphinx:smart_index'
|
67
|
+
end
|
68
|
+
|
69
|
+
unless Rake::Task.task_defined?('thinking_sphinx:index')
|
70
|
+
require 'thinking_sphinx/tasks'
|
71
|
+
end
|
72
|
+
|
73
|
+
# Ensure that indexing does not conflict with ts-resque-delta delta jobs.
|
74
|
+
Rake::Task['thinking_sphinx:index'].enhance ['thinking_sphinx:lock_deltas'] do
|
75
|
+
Rake::Task['thinking_sphinx:unlock_deltas'].invoke
|
76
|
+
end
|
77
|
+
|
78
|
+
Rake::Task['thinking_sphinx:reindex'].enhance ['thinking_sphinx:lock_deltas'] do
|
79
|
+
Rake::Task['thinking_sphinx:unlock_deltas'].invoke
|
22
80
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -6,33 +6,64 @@ describe ThinkingSphinx::Deltas::ResqueDelta::DeltaJob do
|
|
6
6
|
ThinkingSphinx.suppress_delta_output = false
|
7
7
|
ThinkingSphinx::Deltas::ResqueDelta::DeltaJob.stub(:` => true)
|
8
8
|
ThinkingSphinx::Deltas::ResqueDelta::DeltaJob.stub(:puts => nil)
|
9
|
+
ThinkingSphinx::Deltas::ResqueDelta.stub(:locked?).and_return(false)
|
9
10
|
end
|
10
11
|
|
11
12
|
it "should output the delta indexing by default" do
|
12
13
|
ThinkingSphinx::Deltas::ResqueDelta::DeltaJob.should_receive(:puts)
|
13
|
-
ThinkingSphinx::Deltas::ResqueDelta::DeltaJob.perform(
|
14
|
+
ThinkingSphinx::Deltas::ResqueDelta::DeltaJob.perform(
|
15
|
+
['foo_delta']
|
16
|
+
)
|
14
17
|
end
|
15
18
|
|
16
19
|
it "should not output the delta indexing if requested" do
|
17
20
|
ThinkingSphinx.suppress_delta_output = true
|
18
21
|
ThinkingSphinx::Deltas::ResqueDelta::DeltaJob.should_not_receive(:puts)
|
19
|
-
ThinkingSphinx::Deltas::ResqueDelta::DeltaJob.perform(
|
22
|
+
ThinkingSphinx::Deltas::ResqueDelta::DeltaJob.perform(
|
23
|
+
['foo_delta']
|
24
|
+
)
|
20
25
|
end
|
21
26
|
|
22
27
|
it "should process just the requested indexes" do
|
23
|
-
ThinkingSphinx::Deltas::ResqueDelta::DeltaJob.should_receive(:`) do |
|
24
|
-
|
25
|
-
|
28
|
+
ThinkingSphinx::Deltas::ResqueDelta::DeltaJob.should_receive(:`) do |c|
|
29
|
+
c.should match(/foo_delta/)
|
30
|
+
c.should_not match(/--all/)
|
26
31
|
end
|
27
|
-
ThinkingSphinx::Deltas::ResqueDelta::DeltaJob.perform(
|
32
|
+
ThinkingSphinx::Deltas::ResqueDelta::DeltaJob.perform(
|
33
|
+
['foo_delta']
|
34
|
+
)
|
28
35
|
end
|
29
36
|
|
30
37
|
context 'multiple indexes' do
|
31
38
|
it "should process all requested indexes" do
|
32
|
-
ThinkingSphinx::Deltas::ResqueDelta::DeltaJob.should_receive(:`) do |
|
33
|
-
|
39
|
+
ThinkingSphinx::Deltas::ResqueDelta::DeltaJob.should_receive(:`) do |c|
|
40
|
+
c.should match(/foo_delta bar_delta/)
|
34
41
|
end
|
35
|
-
ThinkingSphinx::Deltas::ResqueDelta::DeltaJob.perform(
|
42
|
+
ThinkingSphinx::Deltas::ResqueDelta::DeltaJob.perform(
|
43
|
+
['foo_delta', 'bar_delta']
|
44
|
+
)
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
context 'when an index is locked' do
|
49
|
+
before do
|
50
|
+
ThinkingSphinx::Deltas::ResqueDelta.stub(:locked?) do |index_name|
|
51
|
+
index_name == 'foo_delta' ? true : false
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should not start the indexer" do
|
56
|
+
ThinkingSphinx::Deltas::ResqueDelta::DeltaJob.should_not_receive(:`)
|
57
|
+
ThinkingSphinx::Deltas::ResqueDelta::DeltaJob.perform(
|
58
|
+
['foo_delta']
|
59
|
+
)
|
60
|
+
end
|
61
|
+
|
62
|
+
it "should not start the indexer for multiple indexes" do
|
63
|
+
ThinkingSphinx::Deltas::ResqueDelta::DeltaJob.should_not_receive(:`)
|
64
|
+
ThinkingSphinx::Deltas::ResqueDelta::DeltaJob.perform(
|
65
|
+
['bar_delta', 'foo_delta']
|
66
|
+
)
|
36
67
|
end
|
37
68
|
end
|
38
69
|
end
|
@@ -5,19 +5,19 @@ describe ThinkingSphinx::Deltas::ResqueDelta::FlagAsDeletedJob do
|
|
5
5
|
before :each do
|
6
6
|
ThinkingSphinx.updates_enabled = true
|
7
7
|
@client = stub('client', :update => true)
|
8
|
-
ThinkingSphinx::Configuration.instance.stub
|
9
|
-
ThinkingSphinx.stub
|
10
|
-
ThinkingSphinx.stub
|
8
|
+
ThinkingSphinx::Configuration.instance.stub(:client => @client)
|
9
|
+
ThinkingSphinx.stub(:search_for_id => true)
|
10
|
+
ThinkingSphinx.stub(:sphinx_running? => true)
|
11
11
|
end
|
12
12
|
|
13
13
|
it "should not update if Sphinx isn't running" do
|
14
|
-
ThinkingSphinx.stub
|
14
|
+
ThinkingSphinx.stub(:sphinx_running? => false)
|
15
15
|
@client.should_not_receive(:update)
|
16
16
|
ThinkingSphinx::Deltas::ResqueDelta::FlagAsDeletedJob.perform(['foo_core'], 12)
|
17
17
|
end
|
18
18
|
|
19
19
|
it "should not update if the document isn't in the index" do
|
20
|
-
ThinkingSphinx.stub
|
20
|
+
ThinkingSphinx.stub(:search_for_id => false)
|
21
21
|
@client.should_not_receive(:update)
|
22
22
|
ThinkingSphinx::Deltas::ResqueDelta::FlagAsDeletedJob.perform(['foo_core'], 12)
|
23
23
|
end
|
@@ -6,21 +6,25 @@ describe ThinkingSphinx::Deltas::ResqueDelta do
|
|
6
6
|
ThinkingSphinx.updates_enabled = true
|
7
7
|
ThinkingSphinx.deltas_enabled = true
|
8
8
|
|
9
|
-
Resque.stub
|
9
|
+
Resque.stub(:enqueue => true)
|
10
10
|
|
11
11
|
@delayed_delta = ThinkingSphinx::Deltas::ResqueDelta.new(
|
12
12
|
stub('instance'), {}
|
13
13
|
)
|
14
|
-
@delayed_delta.stub
|
14
|
+
@delayed_delta.stub(:toggled).and_return(true)
|
15
|
+
|
16
|
+
ThinkingSphinx::Deltas::ResqueDelta.stub(:lock)
|
17
|
+
ThinkingSphinx::Deltas::ResqueDelta.stub(:unlock)
|
18
|
+
ThinkingSphinx::Deltas::ResqueDelta.stub(:locked?).and_return(false)
|
15
19
|
|
16
20
|
@model = stub('foo')
|
17
|
-
@model.stub
|
18
|
-
@model.stub
|
19
|
-
@model.stub
|
20
|
-
@model.stub
|
21
|
+
@model.stub(:name => 'foo')
|
22
|
+
@model.stub(:source_of_sphinx_index => @model)
|
23
|
+
@model.stub(:core_index_names => ['foo_core'])
|
24
|
+
@model.stub(:delta_index_names => ['foo_delta'])
|
21
25
|
|
22
26
|
@instance = stub('instance')
|
23
|
-
@instance.stub
|
27
|
+
@instance.stub(:sphinx_document_id => 42)
|
24
28
|
end
|
25
29
|
|
26
30
|
context 'updates disabled' do
|
@@ -57,7 +61,7 @@ describe ThinkingSphinx::Deltas::ResqueDelta do
|
|
57
61
|
|
58
62
|
context "instance isn't toggled" do
|
59
63
|
before :each do
|
60
|
-
@delayed_delta.stub
|
64
|
+
@delayed_delta.stub(:toggled => false)
|
61
65
|
end
|
62
66
|
|
63
67
|
it "should not enqueue a delta job" do
|
@@ -71,23 +75,44 @@ describe ThinkingSphinx::Deltas::ResqueDelta do
|
|
71
75
|
end
|
72
76
|
end
|
73
77
|
|
74
|
-
it "should enqueue a delta job
|
75
|
-
Resque.should_receive(:enqueue).
|
78
|
+
it "should enqueue a delta job" do
|
79
|
+
Resque.should_receive(:enqueue).at_least(:once).with(
|
80
|
+
ThinkingSphinx::Deltas::ResqueDelta::DeltaJob,
|
81
|
+
['foo_delta']
|
82
|
+
)
|
76
83
|
@delayed_delta.index(@model)
|
77
84
|
end
|
78
85
|
|
79
|
-
it "should enqueue a flag-as-deleted job
|
80
|
-
|
81
|
-
|
82
|
-
|
86
|
+
it "should enqueue a flag-as-deleted job" do
|
87
|
+
Resque.should_receive(:enqueue).at_least(:once).with(
|
88
|
+
ThinkingSphinx::Deltas::ResqueDelta::FlagAsDeletedJob,
|
89
|
+
['foo_core'],
|
90
|
+
42
|
91
|
+
)
|
83
92
|
@delayed_delta.index(@model, @instance)
|
84
93
|
end
|
85
94
|
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
95
|
+
context "delta index is locked" do
|
96
|
+
before :each do
|
97
|
+
ThinkingSphinx::Deltas::ResqueDelta.stub(:locked?).and_return(true)
|
98
|
+
end
|
99
|
+
|
100
|
+
it "should not enqueue a delta job" do
|
101
|
+
Resque.should_not_receive(:enqueue).with(
|
102
|
+
ThinkingSphinx::Deltas::ResqueDelta::DeltaJob,
|
103
|
+
['foo_delta']
|
104
|
+
)
|
105
|
+
@delayed_delta.index(@model, @instance)
|
106
|
+
end
|
107
|
+
|
108
|
+
it "should enqueue a flag-as-deleted job" do
|
109
|
+
Resque.should_receive(:enqueue).at_least(:once).with(
|
110
|
+
ThinkingSphinx::Deltas::ResqueDelta::FlagAsDeletedJob,
|
111
|
+
['foo_core'],
|
112
|
+
42
|
113
|
+
)
|
114
|
+
@delayed_delta.index(@model, @instance)
|
115
|
+
end
|
91
116
|
end
|
92
117
|
end
|
93
118
|
end
|
data/ts-resque-delta.gemspec
CHANGED
@@ -8,7 +8,7 @@ Gem::Specification.new do |s|
|
|
8
8
|
s.platform = Gem::Platform::RUBY
|
9
9
|
s.authors = ["Aaron Gibralter"]
|
10
10
|
s.email = ["aaron.gibralter@gmail.com"]
|
11
|
-
s.homepage = "
|
11
|
+
s.homepage = "https://github.com/agibralter/ts-resque-delta"
|
12
12
|
s.summary = %q{Thinking Sphinx - Resque Deltas}
|
13
13
|
s.description = %q{Manage delta indexes via Resque for Thinking Sphinx}
|
14
14
|
|
@@ -26,4 +26,9 @@ Gem::Specification.new do |s|
|
|
26
26
|
s.add_development_dependency "rspec", "~> 1"
|
27
27
|
s.add_development_dependency "cucumber", ">= 0"
|
28
28
|
s.add_development_dependency "database_cleaner", ">= 0.5.2"
|
29
|
+
s.add_development_dependency "mysql"
|
30
|
+
s.add_development_dependency "SystemTimer"
|
31
|
+
s.add_development_dependency "rake", "0.8.7"
|
32
|
+
s.add_development_dependency "ruby-debug"
|
33
|
+
s.add_development_dependency "activerecord", "~> 2.3.11"
|
29
34
|
end
|
metadata
CHANGED
@@ -1,13 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ts-resque-delta
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
hash:
|
4
|
+
hash: 23
|
5
5
|
prerelease:
|
6
6
|
segments:
|
7
|
+
- 1
|
7
8
|
- 0
|
8
9
|
- 0
|
9
|
-
|
10
|
-
version: 0.0.6
|
10
|
+
version: 1.0.0
|
11
11
|
platform: ruby
|
12
12
|
authors:
|
13
13
|
- Aaron Gibralter
|
@@ -15,8 +15,7 @@ autorequire:
|
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
17
|
|
18
|
-
date: 2011-
|
19
|
-
default_executable:
|
18
|
+
date: 2011-05-31 00:00:00 Z
|
20
19
|
dependencies:
|
21
20
|
- !ruby/object:Gem::Dependency
|
22
21
|
name: thinking-sphinx
|
@@ -109,6 +108,80 @@ dependencies:
|
|
109
108
|
version: 0.5.2
|
110
109
|
type: :development
|
111
110
|
version_requirements: *id006
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: mysql
|
113
|
+
prerelease: false
|
114
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
115
|
+
none: false
|
116
|
+
requirements:
|
117
|
+
- - ">="
|
118
|
+
- !ruby/object:Gem::Version
|
119
|
+
hash: 3
|
120
|
+
segments:
|
121
|
+
- 0
|
122
|
+
version: "0"
|
123
|
+
type: :development
|
124
|
+
version_requirements: *id007
|
125
|
+
- !ruby/object:Gem::Dependency
|
126
|
+
name: SystemTimer
|
127
|
+
prerelease: false
|
128
|
+
requirement: &id008 !ruby/object:Gem::Requirement
|
129
|
+
none: false
|
130
|
+
requirements:
|
131
|
+
- - ">="
|
132
|
+
- !ruby/object:Gem::Version
|
133
|
+
hash: 3
|
134
|
+
segments:
|
135
|
+
- 0
|
136
|
+
version: "0"
|
137
|
+
type: :development
|
138
|
+
version_requirements: *id008
|
139
|
+
- !ruby/object:Gem::Dependency
|
140
|
+
name: rake
|
141
|
+
prerelease: false
|
142
|
+
requirement: &id009 !ruby/object:Gem::Requirement
|
143
|
+
none: false
|
144
|
+
requirements:
|
145
|
+
- - "="
|
146
|
+
- !ruby/object:Gem::Version
|
147
|
+
hash: 49
|
148
|
+
segments:
|
149
|
+
- 0
|
150
|
+
- 8
|
151
|
+
- 7
|
152
|
+
version: 0.8.7
|
153
|
+
type: :development
|
154
|
+
version_requirements: *id009
|
155
|
+
- !ruby/object:Gem::Dependency
|
156
|
+
name: ruby-debug
|
157
|
+
prerelease: false
|
158
|
+
requirement: &id010 !ruby/object:Gem::Requirement
|
159
|
+
none: false
|
160
|
+
requirements:
|
161
|
+
- - ">="
|
162
|
+
- !ruby/object:Gem::Version
|
163
|
+
hash: 3
|
164
|
+
segments:
|
165
|
+
- 0
|
166
|
+
version: "0"
|
167
|
+
type: :development
|
168
|
+
version_requirements: *id010
|
169
|
+
- !ruby/object:Gem::Dependency
|
170
|
+
name: activerecord
|
171
|
+
prerelease: false
|
172
|
+
requirement: &id011 !ruby/object:Gem::Requirement
|
173
|
+
none: false
|
174
|
+
requirements:
|
175
|
+
- - ~>
|
176
|
+
- !ruby/object:Gem::Version
|
177
|
+
hash: 21
|
178
|
+
segments:
|
179
|
+
- 2
|
180
|
+
- 3
|
181
|
+
- 11
|
182
|
+
version: 2.3.11
|
183
|
+
type: :development
|
184
|
+
version_requirements: *id011
|
112
185
|
description: Manage delta indexes via Resque for Thinking Sphinx
|
113
186
|
email:
|
114
187
|
- aaron.gibralter@gmail.com
|
@@ -146,8 +219,7 @@ files:
|
|
146
219
|
- tasks/rails.rake
|
147
220
|
- tasks/testing.rb
|
148
221
|
- ts-resque-delta.gemspec
|
149
|
-
|
150
|
-
homepage: http://github.com/agibralter/ts-resque-delta
|
222
|
+
homepage: https://github.com/agibralter/ts-resque-delta
|
151
223
|
licenses: []
|
152
224
|
|
153
225
|
post_install_message:
|
@@ -176,7 +248,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
176
248
|
requirements: []
|
177
249
|
|
178
250
|
rubyforge_project: ts-resque-delta
|
179
|
-
rubygems_version: 1.
|
251
|
+
rubygems_version: 1.7.2
|
180
252
|
signing_key:
|
181
253
|
specification_version: 3
|
182
254
|
summary: Thinking Sphinx - Resque Deltas
|
@@ -194,3 +266,4 @@ test_files:
|
|
194
266
|
- spec/thinking_sphinx/deltas/resque_delta/delta_job_spec.rb
|
195
267
|
- spec/thinking_sphinx/deltas/resque_delta/flag_as_deleted_job_spec.rb
|
196
268
|
- spec/thinking_sphinx/deltas/resque_delta_spec.rb
|
269
|
+
has_rdoc:
|