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

Optimize edge case in throttle enumerator #87

Merged
merged 1 commit into from
Nov 11, 2021
Merged

Optimize edge case in throttle enumerator #87

merged 1 commit into from
Nov 11, 2021

Conversation

vahe
Copy link
Contributor

@vahe vahe commented May 13, 2021

Currently when using the throttle enumerator, even when throttled, the first value of the passed enumerator is evaluated.
This may be problematic in cases when we're throttling based on database health, as we will still perform an ActiveRecord query when throttled.

This PR updates the throttle enumerator to check the throttler before evaluating the next value.

@vahe vahe requested a review from sambostock August 26, 2021 16:19
@vahe
Copy link
Contributor Author

vahe commented Aug 26, 2021

@sambostock I see you contributed to this repo so requesting a review :) Can you 👀 this and see if this change makes sense?

@sambostock
Copy link
Contributor

The implementation seems reasonable. Is there a test we can add or update to verify the behaviour?

@vahe vahe marked this pull request as ready for review November 10, 2021 23:36
@vahe vahe requested review from tgwizard and hyhuang1218 November 10, 2021 23:37
Copy link

@hyhuang1218 hyhuang1218 left a comment

Choose a reason for hiding this comment

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

👍

test/unit/throttle_enumerator_test.rb Outdated Show resolved Hide resolved
Copy link

@tgwizard tgwizard left a comment

Choose a reason for hiding this comment

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

LGTM, 👍 on @sambostock's comment.

@vahe vahe merged commit bcf2892 into master Nov 11, 2021
@shopify-shipit shopify-shipit bot temporarily deployed to rubygems November 11, 2021 14:06 Inactive
@shopify-shipit shopify-shipit bot temporarily deployed to rubygems January 18, 2022 12:25 Inactive
@sambostock sambostock deleted the vahe-patch-1 branch February 6, 2024 15:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants