Class: ThinkingSphinx::Deltas::DelayedDelta
- Inherits:
-
DefaultDelta
- Object
- DefaultDelta
- ThinkingSphinx::Deltas::DelayedDelta
show all
- Includes:
- Binary, SphinxQL
- Defined in:
- lib/thinking_sphinx/deltas/delayed_delta.rb
Overview
Delayed Deltas for Thinking Sphinx, using Delayed Job.
This documentation is aimed at those reading the code. If you’re looking for a guide to Thinking Sphinx and/or deltas, I recommend you start with the Thinking Sphinx site instead - or the README for this library at the very least.
Defined Under Namespace
Modules: Binary, SphinxQL
Constant Summary
collapse
- CONFIGURATIONS_MAP =
{
:priority => :delayed_job_priority,
:queue => :delayed_job_queue
}
Class Method Summary
collapse
Methods included from SphinxQL
#delete, #index
Methods included from Binary
#index
Class Method Details
.cancel_jobs ⇒ Object
22
23
24
25
26
|
# File 'lib/thinking_sphinx/deltas/delayed_delta.rb', line 22
def self.cancel_jobs
Delayed::Job.delete_all([
"handler LIKE (?) AND locked_at IS NULL AND locked_by IS NULL AND failed_at IS NULL", "--- !ruby/object:ThinkingSphinx::Deltas::%"
])
end
|
.enqueue_unless_duplicates(object) ⇒ Object
28
29
30
31
32
33
34
35
36
37
38
39
40
|
# File 'lib/thinking_sphinx/deltas/delayed_delta.rb', line 28
def self.enqueue_unless_duplicates(object)
if Delayed::Job.respond_to?(:where)
return if Delayed::Job.where(
:handler => object.to_yaml, :locked_at => nil
).count > 0
else
return if Delayed::Job.count(
:conditions => {:handler => object.to_yaml, :locked_at => nil}
) > 0
end
Delayed::Job.enqueue object, job_options
end
|
.job_options ⇒ Object
42
43
44
45
46
47
48
49
50
51
52
|
# File 'lib/thinking_sphinx/deltas/delayed_delta.rb', line 42
def self.job_options
if Gem.loaded_specs['delayed_job'].version.to_s.match(/^2\.0\./)
set_job_options(:delayed_job_priority)
else
CONFIGURATIONS_MAP.inject({}) do |job_mapper, configuration_entity|
job_mapper.merge(configuration_entity[0] => set_job_options(configuration_entity[1]))
end
end
end
|
.set_job_options(setting) ⇒ Object
54
55
56
57
58
59
60
61
62
63
|
# File 'lib/thinking_sphinx/deltas/delayed_delta.rb', line 54
def self.set_job_options(setting)
configuration = ThinkingSphinx::Configuration.instance
if configuration.respond_to? setting
configuration.send(setting)
elsif configuration.respond_to? :settings
configuration.settings[setting.to_s]
else
nil
end
end
|