Skip to content

Optimize edge case in throttle enumerator#87

Merged
vahe merged 1 commit into
masterfrom
vahe-patch-1
Nov 11, 2021
Merged

Optimize edge case in throttle enumerator#87
vahe merged 1 commit into
masterfrom
vahe-patch-1

Conversation

@vahe

@vahe vahe commented May 13, 2021

Copy link
Copy Markdown
Contributor

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

vahe commented Aug 26, 2021

Copy link
Copy Markdown
Contributor Author

@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
Copy Markdown
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 hyhuang1218 and tgwizard November 10, 2021 23:37

@hyhuang1218 hyhuang1218 left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

👍

Comment thread test/unit/throttle_enumerator_test.rb Outdated

@tgwizard tgwizard left a comment

Copy link
Copy Markdown

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