Skip to content

Feature request: simplify BatchProcessor by merging async and sync processing functions into one class #1680

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

Closed
2 tasks done
am29d opened this issue Sep 14, 2023 · 3 comments
Assignees
Labels
batch This item relates to the Batch Processing Utility feature-request This item refers to a feature request for an existing or new utility rejected This is something we will not be working on. At least, not in the measurable future

Comments

@am29d
Copy link
Contributor

am29d commented Sep 14, 2023

Use case

During the implementation of the Batch utility we heavily leaned into the Powertools python implementation and create two classes AsyncBatchProcessor and BatchProcessor. After the refactoring in #1677 we realised that we can implement process and processSync functions in one class.

Solution/User Experience

Create one class with two method for async processing as default and sync processing with sync suffix:

class BatchProcessor extends BasePartialBatchProcessor {
  public async processRecord(
    record: BaseRecord
  ): Promise<SuccessResponse | FailureResponse> {
 
  }

  /**
   * Process a record with instance's handler
   * @param _record Batch record to be processed
   * @returns response of success or failure
   */
  public processRecordSync(
    _record: BaseRecord
  ): SuccessResponse | FailureResponse {
  }
}

Alternative solutions

No response

Acknowledgment

Future readers

Please react with 👍 and your use case to help us understand customer demand.

@am29d am29d added feature-request This item refers to a feature request for an existing or new utility confirmed The scope is clear, ready for implementation batch This item relates to the Batch Processing Utility labels Sep 14, 2023
@am29d am29d self-assigned this Sep 14, 2023
@am29d
Copy link
Contributor Author

am29d commented Sep 14, 2023

We have decided to leave the current implementation to let the developer make an explicit choice when to use sync and async batch processors. Otherwise we would have cases where we can register an async function and call sync processing and vice versa. This might lead to lack of information why certain functions failed during runtime.

By having explicit classes the developer would start with the core assumption what type of function they use for the batch processing.

@am29d am29d closed this as completed Sep 14, 2023
@github-project-automation github-project-automation bot moved this from Working on it to Coming soon in Powertools for AWS Lambda (TypeScript) Sep 14, 2023
@github-actions
Copy link
Contributor

⚠️ COMMENT VISIBILITY WARNING ⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

@dreamorosi dreamorosi reopened this Sep 14, 2023
@dreamorosi dreamorosi closed this as not planned Won't fix, can't repro, duplicate, stale Sep 14, 2023
@github-actions
Copy link
Contributor

⚠️ COMMENT VISIBILITY WARNING ⚠️

Comments on closed issues are hard for our team to see.
If you need more assistance, please either tag a team member or open a new issue that references this one.
If you wish to keep having a conversation with other community members under this issue feel free to do so.

@dreamorosi dreamorosi moved this from Coming soon to Closed in Powertools for AWS Lambda (TypeScript) Sep 15, 2023
@dreamorosi dreamorosi added rejected This is something we will not be working on. At least, not in the measurable future and removed confirmed The scope is clear, ready for implementation labels Sep 15, 2023
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 feature-request This item refers to a feature request for an existing or new utility rejected This is something we will not be working on. At least, not in the measurable future
Projects
Development

No branches or pull requests

2 participants