Class: XapianDb::IndexWriters::SidekiqWriter

Inherits:
Object
  • Object
show all
Defined in:
lib/xapian_db/index_writers/sidekiq_writer.rb

Class Method Summary collapse

Class Method Details

.delete_doc_with(xapian_id, _commit = true) ⇒ Object

Remove an object from the index

Parameters:

  • xapian_id (String)

    The document id



33
34
35
36
37
38
# File 'lib/xapian_db/index_writers/sidekiq_writer.rb', line 33

def delete_doc_with(xapian_id, _commit= true)
  Sidekiq::Client.push('queue' => queue,
                       'class' => worker_class,
                       'args' => ['delete_doc', { xapian_id: xapian_id }.to_json],
                       'retry' => sidekiq_retry)
end

.index(obj, _commit = true, changed_attrs: []) ⇒ Object

Update an object in the index

Parameters:

  • obj (Object)

    An instance of a class with a blueprint configuration



24
25
26
27
28
29
# File 'lib/xapian_db/index_writers/sidekiq_writer.rb', line 24

def index(obj, _commit= true, changed_attrs: [])
  Sidekiq::Client.push('queue' => queue,
                       'class' => worker_class,
                       'args' => ['index', { class: obj.class.name, id: obj.id, changed_attrs: changed_attrs }.to_json],
                       'retry' => sidekiq_retry)
end

.queueObject



18
19
20
# File 'lib/xapian_db/index_writers/sidekiq_writer.rb', line 18

def queue
  XapianDb::Config.sidekiq_queue
end

.reindex_class(klass, _options = {}) ⇒ Object

Reindex all objects of a given class

Parameters:

  • klass (Class)

    The class to reindex



42
43
44
45
46
47
# File 'lib/xapian_db/index_writers/sidekiq_writer.rb', line 42

def reindex_class(klass, _options = {})
  Sidekiq::Client.push('queue' => queue,
                       'class' => worker_class,
                       'args' => ['reindex_class', { class: klass.name }.to_json],
                       'retry' => sidekiq_retry)
end

.set_max_expansionObject



49
50
51
# File 'lib/xapian_db/index_writers/sidekiq_writer.rb', line 49

def set_max_expansion
  XapianDb::Config.set_max_expansion
end

.sidekiq_retryObject



53
54
55
# File 'lib/xapian_db/index_writers/sidekiq_writer.rb', line 53

def sidekiq_retry
  XapianDb::Config.sidekiq_retry
end

.worker_classObject



57
58
59
# File 'lib/xapian_db/index_writers/sidekiq_writer.rb', line 57

def worker_class
  SidekiqWorker
end