Sha256: 78a57a115f00b028a173235f58720ab68cd8028f54205eac47ee7edfd13cc508
Contents?: true
Size: 1 KB
Versions: 17
Compression:
Stored size: 1 KB
Contents
# frozen_string_literal: true class ThinkingSphinx::Middlewares::StaleIdFilter < ThinkingSphinx::Middlewares::Middleware 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 private def append_stale_ids(ids, context) @stale_ids |= ids context.search.options[:without_ids] ||= [] context.search.options[:without_ids] |= ids end def log_message 'Stale Ids (%s %s left): %s' % [ @retries, (@retries == 1 ? 'try' : 'tries'), @stale_ids.join(', ') ] end def stale_retries case context.search.options[:retry_stale] when nil, TrueClass 2 when FalseClass 0 else context.search.options[:retry_stale].to_i end end end
Version data entries
17 entries across 17 versions & 1 rubygems