Class: Neuromancer::Indexer::Client
- Inherits:
-
Object
- Object
- Neuromancer::Indexer::Client
- Defined in:
- lib/neuromancer/indexer/client.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
Instance Method Summary collapse
- #delete(id:, type:) ⇒ Object
- #enqueue(action:, document:) ⇒ Object
- #index(id:, type:, attributes:) ⇒ Object
-
#initialize(sqs = nil) ⇒ Client
constructor
A new instance of Client.
Constructor Details
#initialize(sqs = nil) ⇒ Client
Returns a new instance of Client.
8 9 10 11 |
# File 'lib/neuromancer/indexer/client.rb', line 8 def initialize(sqs = nil) @config = Neuromancer::Indexer.config @sqs = sqs end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
6 7 8 |
# File 'lib/neuromancer/indexer/client.rb', line 6 def config @config end |
Instance Method Details
#delete(id:, type:) ⇒ Object
20 21 22 23 24 25 |
# File 'lib/neuromancer/indexer/client.rb', line 20 def delete(id:, type:) document = Document.new(id: id, type: type, attributes: {}) document.validate! enqueue(action: 'delete', document: document) end |
#enqueue(action:, document:) ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/neuromancer/indexer/client.rb', line 27 def enqueue(action:, document:) = { action: action, document: document } sqs.( queue_url: config.sqs_url, message_body: .to_json, delay_seconds: 1 ) end |