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: terminateVisibilityTimeout = number to customise the timeout #520

Merged

Conversation

Frederick888
Copy link
Contributor

@Frederick888 Frederick888 commented Oct 10, 2024

Resolves #523

Description:
This allows users to introduce a delay before the message can be received again. In some cases this can improve the overall success rate.

Type of change:

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)

Why is this change required?:
When tasks are not time critical, a small delay can mitigate some intermittent errors, or give supervisors like K8s a little time to kill broken consumers.

Code changes:

  • terminateVisibilityTimeout option has been updated to accept custom visibility timeouts.

I reused the option as I thought it was the most non-intrusive way to introduce this feature. If it appears to be confusing, I can also add a new option. But since the underlying SQS command is the same, I think it's ok.


Checklist:

  • My code follows the code style of this project.
  • My change requires a change to the documentation.
  • I have updated the documentation accordingly.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.

Copy link

github-actions bot commented Oct 10, 2024

CLA Assistant Lite bot CLA CHECK All Contributors have signed the CLA

@Frederick888
Copy link
Contributor Author

I have read the CLA Document and I hereby sign the CLA

@Frederick888 Frederick888 marked this pull request as ready for review October 10, 2024 09:53
@Frederick888 Frederick888 requested review from a team as code owners October 10, 2024 09:53
src/consumer.ts Outdated
if (this.terminateVisibilityTimeout) {
await this.changeVisibilityTimeout(message, 0);
if (this.terminateVisibilityTimeout !== false) {
const timeout = this.terminateVisibilityTimeout === true ? 0 : this.terminateVisibilityTimeout
Copy link
Member

Choose a reason for hiding this comment

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

Thanks for the PR, this makes sense. I am currently thinking if it makes sense to add a new option though (terminateVisibilityTimeoutMs) rather than this logic and then just default that to 0 and allow it to be changed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the review! To be honest I'm on the fence too. If we reuse the terminateVisibilityTimeout option, the naming is a bit confusing; if we add a terminateVisibilityTimeoutMs, without looking at their types, there will appear to be a timeout and a timeout in milliseconds at the same time, and I'm not sure what should happen if terminateVisibilityTimeout == false but terminateVisibilityTimeoutMs is set.

I'm happy to leave the decision to you. I can update the code and docs if you opt for a new option in the end.

PS: Forgot to npm run format. Just pushed :)

Copy link
Member

Choose a reason for hiding this comment

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

Yeah that makes sense too, I think I'll just merge this into canary for now and think on it, if I don't decide against it by Wednesday, I'll push it up to main.

Thanks a lot for the contribution!

This allows users to introduce a delay before the message can be
received again. In some cases this can improve the overall success rate.
@nicholasgriffintn nicholasgriffintn merged commit e09c759 into bbc:canary Oct 14, 2024
12 of 13 checks passed
@github-actions github-actions bot locked and limited conversation to collaborators Oct 14, 2024
@Frederick888 Frederick888 deleted the custom-vis-timeout-on-err branch October 14, 2024 12:50
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Custom new visibility timeout on processing errors
2 participants