Module: SequelTextSearchable

Defined in:
lib/sequel/text_searchable.rb

Constant Summary collapse

VERSION =
"0.0.1"
INDEX_MODES =
[:async, :sync, :off].freeze
DEFAULT_MODE =
:async

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.threadpoolObject

Return the global threadpool for :async indexing. Use at most a couple threads; if the work gets backed up, have the caller run it. If the threads die, the text update is lost, so we don’t want to let it queue up forever.



26
27
28
29
30
31
32
33
# File 'lib/sequel/text_searchable.rb', line 26

def threadpool
  return @threadpool ||= Concurrent::ThreadPoolExecutor.new(
    min_threads: 1,
    max_threads: 2,
    max_queue: 10,
    fallback_policy: :caller_runs,
  )
end

Class Method Details

.index_modeObject



12
# File 'lib/sequel/text_searchable.rb', line 12

def index_mode = @index_mode || DEFAULT_MODE

.index_mode=(v) ⇒ Object

Raises:

  • (ArgumentError)


14
15
16
17
18
# File 'lib/sequel/text_searchable.rb', line 14

def index_mode=(v)
  raise ArgumentError, "mode #{v.inspect} must be one of: #{INDEX_MODES}" unless
    INDEX_MODES.include?(v)
  @index_mode = v
end

.reindex_allObject



38
39
40
# File 'lib/sequel/text_searchable.rb', line 38

def reindex_all
  return self.searchable_models.sum(&:text_search_reindex_all)
end

.searchable_modelsObject



20
# File 'lib/sequel/text_searchable.rb', line 20

def searchable_models = @searchable_models ||= []