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

Feature request: allow SqsFifoPartialProcessor to continue processing other group IDs upon failure #2561

Closed
1 of 2 tasks
dreamorosi opened this issue May 21, 2024 · 5 comments · Fixed by #2590
Closed
1 of 2 tasks
Assignees
Labels
batch This item relates to the Batch Processing Utility completed This item is complete and has been merged/shipped feature-request This item refers to a feature request for an existing or new utility

Comments

@dreamorosi
Copy link
Contributor

Use case

Currently the SqsFifoPartialProcessor part of the Batch Processing utility short-circuits by throwing an error as soon as an item in a batch fails to process. This is done to prevent out-of-order processing.

By default, we will stop processing at the first failure and mark unprocessed messages as failed to preserve ordering. However, this behavior may not be optimal for customers who wish to proceed with processing messages from a different group ID.

We should look into adding this feature.

Solution/User Experience

Customers should be able to pass a skipGroupOnError option

This could be done by either accepting an option object when instantiating the processor, like:

import {
  SqsFifoPartialProcessor,
  processPartialResponseSync,
} from '@aws-lambda-powertools/batch';
import type {
CallableFunction
} from '@aws-lambda-powertools/batch/types';

declare recordHandler = CallableFunction;

const processor = new SqsFifoPartialProcessor({ skipGroupOnError: true });  // <-- New option

export const handler = async (
  event,
  context
) => {
  return processPartialResponseSync(event, recordHandler, processor, {
    context,
  });
};

Or by accepting a new option in the already existing option object accepted by the processPartialResponseSync function, like:

import {
  SqsFifoPartialProcessor,
  processPartialResponseSync,
} from '@aws-lambda-powertools/batch';
import type {
CallableFunction
} from '@aws-lambda-powertools/batch/types';

declare recordHandler = CallableFunction;

const processor = new SqsFifoPartialProcessor();

export const handler = async (
  event,
  context
) => {
  return processPartialResponseSync(event, recordHandler, processor, {
    context,
    skipGroupOnError: true // <-- New option
  });
};

The second one is probably more organic and allows customers additional customizability as they can define the value for skipGroupOnError in the context of a specific invocation, however it will likely require some TypeScript generic type so that it's accepted only when the processor parameter is of type SqsFifoPartialProcessor.

Either way, the value for skipGroupOnError should be saved in the SqsFifoPartialProcessor instance and then taken in account when calling the shortCircuitProcessing method to decide whether to throw or not.

Alternative solutions

N/A

Acknowledgment

Future readers

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

@dreamorosi dreamorosi added help-wanted We would really appreciate some support from community for this one 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 May 21, 2024
@arnabrahman
Copy link
Contributor

@dreamorosi , thanks for the nicely detailed instructions. I would like to take a look at this issue.

@dreamorosi
Copy link
Contributor Author

Hi @arnabrahman, sounds good!

If you have any questions please let me know 😊

@dreamorosi
Copy link
Contributor Author

I didn't link it in the issue, but if it helps you can also take a look at the implementation of this feature in the Python version which is in this file here.

Copy link
Contributor

github-actions bot commented Jun 4, 2024

⚠️ COMMENT VISIBILITY WARNING ⚠️

This issue is now closed. Please be mindful that future comments 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.

@github-actions github-actions bot added pending-release This item has been merged and will be released soon and removed help-wanted We would really appreciate some support from community for this one confirmed The scope is clear, ready for implementation labels Jun 4, 2024
Copy link
Contributor

This is now released under v2.2.0 version!

@github-actions github-actions bot added completed This item is complete and has been merged/shipped and removed pending-release This item has been merged and will be released soon labels Jun 13, 2024
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 completed This item is complete and has been merged/shipped feature-request This item refers to a feature request for an existing or new utility
Projects
2 participants