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



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

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
    ThinkingSphinx::Logger.log :message, log_message

    @retries -= 1 and retry
  end
end