Class: ElasticGraph::IndexerLambda::SqsProcessor
- Inherits:
-
Object
- Object
- ElasticGraph::IndexerLambda::SqsProcessor
- Defined in:
- lib/elastic_graph/indexer_lambda/sqs_processor.rb
Overview
Responsible for handling lambda event payloads from an SQS lambda trigger.
Instance Method Summary collapse
-
#initialize(indexer_processor, report_batch_item_failures:, logger:, s3_client: nil) ⇒ SqsProcessor
constructor
A new instance of SqsProcessor.
-
#process(lambda_event, refresh_indices: false) ⇒ Object
Processes the ElasticGraph events in the given ‘lambda_event`, indexing the data in the database.
Constructor Details
#initialize(indexer_processor, report_batch_item_failures:, logger:, s3_client: nil) ⇒ SqsProcessor
Returns a new instance of SqsProcessor.
19 20 21 22 23 24 |
# File 'lib/elastic_graph/indexer_lambda/sqs_processor.rb', line 19 def initialize(indexer_processor, report_batch_item_failures:, logger:, s3_client: nil) @indexer_processor = indexer_processor @report_batch_item_failures = report_batch_item_failures @logger = logger @s3_client = s3_client end |
Instance Method Details
#process(lambda_event, refresh_indices: false) ⇒ Object
Processes the ElasticGraph events in the given ‘lambda_event`, indexing the data in the database.
27 28 29 30 31 32 33 34 35 36 37 38 |
# File 'lib/elastic_graph/indexer_lambda/sqs_processor.rb', line 27 def process(lambda_event, refresh_indices: false) events = events_from(lambda_event) failures = @indexer_processor.process_returning_failures(events, refresh_indices: refresh_indices) if failures.any? failures_error = Indexer::IndexingFailuresError.for(failures: failures, events: events) raise failures_error unless @report_batch_item_failures @logger.error(failures_error.) end format_response(failures) end |