Skip to content
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

feat(batch): Async Processing of Records for for SQS Fifo #3160

Merged
merged 22 commits into from
Nov 8, 2024

Conversation

arnabrahman
Copy link
Contributor

@arnabrahman arnabrahman commented Oct 6, 2024

Summary

SQS Fifo doesn't have an async processing feature. This PR adds the feature to process async records with SQS Fifo.

Changes

  • A new class SqsFifoPartialProcessorAsync is created to handle the async processing.
  • A small util class for SQS FIFO processing, if we agree on this then it can be used inside SqsFifoPartialProcessor
  • Change processPartialResponse & BatchProcessingOptions for SqsFifoPartialProcessorAsync
  • Run the same sets of tests for SqsFifoPartialProcessorAsync as we did for SqsFifoPartialProcessor
  • Update the Fifo related docs for async processing with examples.

Issue number: closes #3140


By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

Disclaimer: We value your time and bandwidth. As such, any pull requests created on non-triaged issues might not be successful.

@boring-cyborg boring-cyborg bot added batch This item relates to the Batch Processing Utility tests PRs that add or change tests labels Oct 6, 2024
@pull-request-size pull-request-size bot added the size/XL PRs between 500-999 LOC, often PRs that grown with feedback label Oct 6, 2024
@arnabrahman
Copy link
Contributor Author

This is the initial implementation of Async processing for FIFO. Using Mixin to decouple common logics. But I might be missing something, please point me to the right direction @dreamorosi

@dreamorosi
Copy link
Contributor

Hi @arnabrahman, thanks for the PR!

I'll review this tomorrow afternoon. I'm currently focused on tomorrow's release and since I think we are still on early phases of the implementation I don't think it'll make it for tomorrow.

@github-actions github-actions bot added the feature PRs that introduce new features or minor changes label Oct 7, 2024
@arnabrahman
Copy link
Contributor Author

@dreamorosi No worries, take your time 🙂

This comment was marked as off-topic.

@github-actions github-actions bot added do-not-merge This item should not be merged need-issue This PR needs an issue before it can be reviewed/worked on further labels Oct 7, 2024
@dreamorosi dreamorosi removed do-not-merge This item should not be merged need-issue This PR needs an issue before it can be reviewed/worked on further labels Oct 7, 2024
@dreamorosi
Copy link
Contributor

Hi @arnabrahman, sorry this is taking a while.

This pattern is completely new to me and so I'm taking some time to read about it and understand the impact and future maintainability.

@dreamorosi
Copy link
Contributor

Hi @arnabrahman - I have a deadline for this year's re:Invent set for Wednesday afternoon. I'm planning on reviewing the PR and provide meaningful feedback by Thursday afternoon.

Sorry for the delay - you know I would not let this stall too long if I really didn't have to.

Thanks for understanding!

@arnabrahman
Copy link
Contributor Author

@dreamorosi, i get it. There's no need to apologize 🙂

@arnabrahman
Copy link
Contributor Author

arnabrahman commented Oct 25, 2024

@dreamorosi, is it ok if i work on other open issues, which are maybe a bit more straightforward than this? As this is in a holding state.

@dreamorosi
Copy link
Contributor

Hi @arnabrahman, thanks for your patience and for the long wait.

I have spent some time looking at this and while the implementation makes sense and works, I am concerned about introducing this pattern in the project.

This is likely a limitation of my understanding of the pattern, despite having spent some time on it, but I don't understand why Mixins in TypeScript can't support protected or private fields. Based on what I was able to gather, TypeScript doesn't allow you to add access properties to Mixin's methods because it ultimately isn't able to represent them in its type definitions (ts(4094) microsoft/TypeScript#30355, microsoft/TypeScript#36060).

Based on these issues, this seems to be still a very much open discussion with different workarounds that all have tradeoffs with non-obvious implications (here's a good summary of them).

Historically, we've been pretty intentional and somewhat strict with the access patterns we use to define methods, and if anything we are only getting stricter with the gradual adoption of actual JavaScript private classifiers (i.e. #foo). This is primarily because we take breaking changes seriously, and in order to do this we must keep our public API as tight as we can.

Having everything public like in the SqsFifo class represents somewhat of a risk in this area since it's an implicit green light for customers to rely on these methods being publics. This is still true even if we consider the fact that we are using the _name prefix, and that the SqsFifo mixin is not supposed to be used directly.

Ultimately, I am not sure that 1/ the ambiguity derived by TypeScript being unsure about how to treat these in type definitions, and 2/ the precedent of adding ambiguous access patterns in the codebase are worth saving some line of code that we'd have to write if we were to represent these with more vanilla inheritance or abstract classes like we already do with other processors in this package - even if this means having some repetition in the code.

I wonder if we could give a try to write this without Mixins and see if the outcome is less problematic. What do you think?

@dreamorosi
Copy link
Contributor

@dreamorosi, is it ok if i work on other open issues, which are maybe a bit more straightforward than this? As this is in a holding state.

Yes please, feel free to pick up any of the existing open issues.

@arnabrahman
Copy link
Contributor Author

@dreamorosi Thanks for your insight on this. I will write this without mixin & give it a try.

@pull-request-size pull-request-size bot added size/L PRs between 100-499 LOC and removed size/XL PRs between 500-999 LOC, often PRs that grown with feedback labels Nov 3, 2024
@boring-cyborg boring-cyborg bot added the documentation Improvements or additions to documentation label Nov 5, 2024
@pull-request-size pull-request-size bot added size/XL PRs between 500-999 LOC, often PRs that grown with feedback and removed size/L PRs between 100-499 LOC labels Nov 5, 2024
@arnabrahman arnabrahman marked this pull request as ready for review November 7, 2024 04:57
@arnabrahman arnabrahman requested review from a team as code owners November 7, 2024 04:57
Copy link
Contributor

@am29d am29d left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for PR! I have minor comments for clarification on the utility class. I also wonder if it would make sense to pull up a SqsFiroProcessor class with the utils functionality for both cases.

packages/batch/src/SqsFifoProcessingUtils.ts Outdated Show resolved Hide resolved
@arnabrahman arnabrahman requested a review from am29d November 8, 2024 08:27
Copy link

sonarqubecloud bot commented Nov 8, 2024

Copy link
Contributor

@am29d am29d left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank for the PR @arnabrahman, great work!

While I have an itch to reduce the code duplication in this PR, @dreamorosi and I agreed to move it to a separate task that would affect the entire batch utility. We could simplify a lot of functionality and have a better implementation for sync and asynchronous processors.

@am29d am29d merged commit e73b575 into aws-powertools:main Nov 8, 2024
25 checks passed
@arnabrahman arnabrahman deleted the 3140-async-fifo-processor branch November 9, 2024 14:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
batch This item relates to the Batch Processing Utility documentation Improvements or additions to documentation feature PRs that introduce new features or minor changes size/XL PRs between 500-999 LOC, often PRs that grown with feedback tests PRs that add or change tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Feature request: Support Sequential Async Processing of Records for SqsFifoPartialProcessor
3 participants