-
Notifications
You must be signed in to change notification settings - Fork 3
VED-859 Improve ack backend efficiency and make completion process more robust #892
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
dlzhry2nhs
merged 9 commits into
master
from
feature/VED-859-improve-ack-backend-process
Oct 10, 2025
Merged
Changes from all commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
65a4c47
Refactor record processor to record the row count
dlzhry2nhs 86e2e19
Baseline get tests working
dlzhry2nhs 6d729a8
Completed test updates
dlzhry2nhs a4455f7
Minor refactoring
dlzhry2nhs 7cb1ebb
Fix pipeline run
dlzhry2nhs ff1c13c
Self review
dlzhry2nhs 2606e31
Baseline lint after rebase
dlzhry2nhs 09b8377
Fix splunk logging tests
dlzhry2nhs d2b8565
PR comments
dlzhry2nhs File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,12 +1,21 @@ | ||
| """Utils for ack lambda""" | ||
|
|
||
| from common.clients import get_s3_client | ||
| from audit_table import get_record_count_by_message_id | ||
|
|
||
| _BATCH_EVENT_ID_TO_RECORD_COUNT_MAP: dict[str, int] = {} | ||
|
|
||
| def get_row_count(bucket_name: str, file_key: str) -> int: | ||
| """ | ||
| Looks in the given bucket and returns the count of the number of lines in the given file. | ||
| NOTE: Blank lines are not included in the count. | ||
| """ | ||
| response = get_s3_client().get_object(Bucket=bucket_name, Key=file_key) | ||
| return sum(1 for line in response["Body"].iter_lines() if line.strip()) | ||
|
|
||
| def is_ack_processing_complete(batch_event_message_id: str, processed_ack_count: int) -> bool: | ||
| """Checks if we have received all the acknowledgement rows for the original source file. Also caches the value of | ||
| the source file record count to reduce traffic to DynamoDB""" | ||
| if batch_event_message_id in _BATCH_EVENT_ID_TO_RECORD_COUNT_MAP: | ||
| return _BATCH_EVENT_ID_TO_RECORD_COUNT_MAP[batch_event_message_id] == processed_ack_count | ||
|
|
||
| record_count = get_record_count_by_message_id(batch_event_message_id) | ||
|
|
||
| if not record_count: | ||
| # Record count is not set on the audit item until all rows have been preprocessed and sent to Kinesis | ||
| return False | ||
|
|
||
| _BATCH_EVENT_ID_TO_RECORD_COUNT_MAP[batch_event_message_id] = record_count | ||
| return record_count == processed_ack_count |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.