Class: ThinkingSphinx::Middlewares::StaleIdFilter

Inherits:
Middleware
  • Object
show all
Defined in:
lib/thinking_sphinx/middlewares/stale_id_filter.rb

Instance Method Summary collapse

Methods inherited from Middleware

#initialize

Constructor Details

This class inherits a constructor from ThinkingSphinx::Middlewares::Middleware

Instance Method Details

#call(contexts) ⇒ Object



6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
# File 'lib/thinking_sphinx/middlewares/stale_id_filter.rb', line 6

def call(contexts)
  @context   = contexts.first
  @stale_ids = []
  @retries   = stale_retries

  begin
    app.call contexts
  rescue ThinkingSphinx::Search::StaleIdsException => error
    raise error if @retries <= 0

    append_stale_ids error.ids, error.context
    ThinkingSphinx::Logger.log :message, log_message

    @retries -= 1 and retry
  end
end