Class: ThinkingSphinx::Deltas::DeltaJob

Inherits:
Object
  • Object
show all
Defined in:
lib/thinking_sphinx/deltas/delayed_delta/delta_job.rb

Overview

A simple job class that processes a given index.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(indices) ⇒ DeltaJob

Initialises the object with an index name.

Parameters:

  • index (String)

    the name of the Sphinx index



10
11
12
# File 'lib/thinking_sphinx/deltas/delayed_delta/delta_job.rb', line 10

def initialize(indices)
  @indices = indices
end

Instance Attribute Details

#indicesObject

Returns the value of attribute indices.



4
5
6
# File 'lib/thinking_sphinx/deltas/delayed_delta/delta_job.rb', line 4

def indices
  @indices
end

Instance Method Details

#display_nameObject

Shows index name in Delayed::Job#name.



16
17
18
# File 'lib/thinking_sphinx/deltas/delayed_delta/delta_job.rb', line 16

def display_name
  "#{self.class.name} for #{indices.join(', ')}"
end

#performBoolean

Runs Sphinx’s indexer tool to process the index. Currently assumes Sphinx is running.

Returns:

  • (Boolean)

    true



25
26
27
28
29
30
31
32
# File 'lib/thinking_sphinx/deltas/delayed_delta/delta_job.rb', line 25

def perform
  config = ThinkingSphinx::Configuration.instance

  output = `#{config.bin_path}#{config.indexer_binary_name} --config "#{config.config_file}" --rotate #{indices.join(' ')}`
  puts output unless ThinkingSphinx.suppress_delta_output?

  true
end