elasticgraph-indexer_lambda 0.18.0.4 → 0.18.0.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: fbd6851f8d0d3b534a29e9966af449fe830e702388add5e59007268718884643
4
- data.tar.gz: f6b8751a60b161d79e8cc59ab959287037cfd7702cc7dac69b584b08c72e8ca0
3
+ metadata.gz: c40fc6f5e803a2355e9c4b5623b7aef3bc98e11c29953c0c31468e4a1c768993
4
+ data.tar.gz: de7c637b901f9e251884056975bd7631f219a6de7dcc2ca17c87e51d0b13ad34
5
5
  SHA512:
6
- metadata.gz: f6d2360305069114468626b67e889d21eaa8a45c269446e995e9eb3fa1c836e32cd54a5bc3717c9c52e13f70155dbe27d045549e68382108440de680e800b67e
7
- data.tar.gz: d534b6e2c0c6c59c5f90ba92b4f79d3c1014a51e3f0074a14c932140e650f19801d49dfc08cfca867e55075d3ae1bce0089f3d3bf4e11388b7efec9805b4bedb
6
+ metadata.gz: 57861df48c60a47828f11c0536b6deadf6639012a93f2bc28a72761e882617e713cde6f66cd2726e996379637ef04a345deb3841d1808ca0c3f0c12fca6bda03
7
+ data.tar.gz: 16463e9a14fbc544983f8dced31f95dca6f132ff0b73dad5f083ac266c9a874870e2aab61374a36571ff7e04250fe80fe913746fb4c0da7596f547faedf31996
@@ -6,7 +6,7 @@
6
6
  #
7
7
  # frozen_string_literal: true
8
8
 
9
- require "elastic_graph/error"
9
+ require "elastic_graph/errors"
10
10
  require "elastic_graph/indexer/indexing_failures_error"
11
11
  require "json"
12
12
 
@@ -23,7 +23,7 @@ module ElasticGraph
23
23
  @s3_client = s3_client
24
24
  end
25
25
 
26
- # Processes the ElasticGraph events in the given `lambda_event`, indexing the data in the database.
26
+ # Processes the ElasticGraph events in the given `lambda_event`, indexing the data in the datastore.
27
27
  def process(lambda_event, refresh_indices: false)
28
28
  events = events_from(lambda_event)
29
29
  failures = @indexer_processor.process_returning_failures(events, refresh_indices: refresh_indices)
@@ -66,12 +66,20 @@ module ElasticGraph
66
66
  # ...
67
67
  # Note: "\n" at the end of each line is a single byte newline control character, instead of a string sequence
68
68
  def events_from(lambda_event)
69
+ sqs_received_at_by_message_id = {} # : Hash[String, String]
69
70
  lambda_event.fetch("Records").flat_map do |record|
70
71
  sqs_metadata = extract_sqs_metadata(record)
71
-
72
+ if (message_id = sqs_metadata.fetch("message_id", nil))
73
+ sqs_received_at_by_message_id[message_id] = sqs_metadata.dig("latency_timestamps", "sqs_received_at")
74
+ end
72
75
  parse_jsonl(record.fetch("body")).map do |event|
73
76
  ElasticGraph::Support::HashUtil.deep_merge(event, sqs_metadata)
74
77
  end
78
+ end.tap do
79
+ @logger.info({
80
+ "message_type" => "ReceivedSqsMessages",
81
+ "sqs_received_at_by_message_id" => sqs_received_at_by_message_id
82
+ })
75
83
  end
76
84
  end
77
85
 
@@ -110,7 +118,7 @@ module ElasticGraph
110
118
  begin
111
119
  s3_client.get_object(bucket: bucket_name, key: object_key).body.read
112
120
  rescue Aws::S3::Errors::ServiceError => e
113
- raise S3OperationFailedError, "Error reading large message from S3. bucket: `#{bucket_name}` key: `#{object_key}` message: `#{e.message}`"
121
+ raise Errors::S3OperationFailedError, "Error reading large message from S3. bucket: `#{bucket_name}` key: `#{object_key}` message: `#{e.message}`"
114
122
  end
115
123
  end
116
124
 
@@ -134,7 +142,7 @@ module ElasticGraph
134
142
  if failure_ids.any? { |f| f.fetch("itemIdentifier").nil? }
135
143
  # If we are not able to identify one or more failed events, then we must raise an exception instead of
136
144
  # returning `batchItemFailures`. Otherwise, the unidentified failed events will not get retried.
137
- raise MessageIdsMissingError, "Unexpected: some failures did not have a `message_id`, so we are raising an exception instead of returning `batchItemFailures`."
145
+ raise Errors::MessageIdsMissingError, "Unexpected: some failures did not have a `message_id`, so we are raising an exception instead of returning `batchItemFailures`."
138
146
  end
139
147
 
140
148
  {"batchItemFailures" => failure_ids}
metadata CHANGED
@@ -1,14 +1,16 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elasticgraph-indexer_lambda
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.18.0.4
4
+ version: 0.18.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Myron Marston
8
+ - Ben VandenBos
9
+ - Square Engineering
8
10
  autorequire:
9
11
  bindir: exe
10
12
  cert_chain: []
11
- date: 2024-09-06 00:00:00.000000000 Z
13
+ date: 2024-09-20 00:00:00.000000000 Z
12
14
  dependencies:
13
15
  - !ruby/object:Gem::Dependency
14
16
  name: rubocop-factory_bot
@@ -190,28 +192,28 @@ dependencies:
190
192
  requirements:
191
193
  - - '='
192
194
  - !ruby/object:Gem::Version
193
- version: 0.18.0.4
195
+ version: 0.18.0.5
194
196
  type: :runtime
195
197
  prerelease: false
196
198
  version_requirements: !ruby/object:Gem::Requirement
197
199
  requirements:
198
200
  - - '='
199
201
  - !ruby/object:Gem::Version
200
- version: 0.18.0.4
202
+ version: 0.18.0.5
201
203
  - !ruby/object:Gem::Dependency
202
204
  name: elasticgraph-lambda_support
203
205
  requirement: !ruby/object:Gem::Requirement
204
206
  requirements:
205
207
  - - '='
206
208
  - !ruby/object:Gem::Version
207
- version: 0.18.0.4
209
+ version: 0.18.0.5
208
210
  type: :runtime
209
211
  prerelease: false
210
212
  version_requirements: !ruby/object:Gem::Requirement
211
213
  requirements:
212
214
  - - '='
213
215
  - !ruby/object:Gem::Version
214
- version: 0.18.0.4
216
+ version: 0.18.0.5
215
217
  - !ruby/object:Gem::Dependency
216
218
  name: aws-sdk-s3
217
219
  requirement: !ruby/object:Gem::Requirement