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

Usefulness of EnumeratorBuilder wrapper #468

Closed
bdewater opened this issue Mar 6, 2024 · 1 comment
Closed

Usefulness of EnumeratorBuilder wrapper #468

bdewater opened this issue Mar 6, 2024 · 1 comment

Comments

@bdewater
Copy link
Contributor

bdewater commented Mar 6, 2024

I've been wondering why this exists since it seems unused. The documentation states:

# These wrappers ensure we have a custom type that we can assert on in
# Iteration. It's useful that the `wrapper` passed to EnumeratorBuilder in
# `enumerator_builder` is _always_ the type that is returned from
# `build_enumerator`. This prevents people from implementing custom
# Enumerators without wrapping them in
# `enumerator_builder.wrap(custom_enum)`. We don't do this yet for backwards
# compatibility with raw calls to EnumeratorBuilder. Think of these wrappers
# the way you should a middleware.

The mention of middleware seems to indicate a way for things like ThrottleEnumerator to be implemented, but right now it seems to only calculate the size of the enumerator (I'm not sure how useful this actually is).

Maybe there's some Shopify internal usage I'm not aware of but my guess is that's not the case given these comments: #91 (comment)

#445 also made it possible to do things around iterations using callbacks.

Try as I might, I can't come up with a use case for it? Seems the options are:

  • add a deprecation warning for unwrapped enumerators, fix the unwrapped enumerators here, document how custom enumerators should wrap)
  • deprecate the wrapper (if used) and remove the thing
  • do nothing 🤷
@bdewater
Copy link
Contributor Author

I ran into @kirs at Rails World and we briefly chatted about this, he confirmed that Shopify's monolith uses the wrapping for a bunch of additional job queue functionality, so deprecation warnings seem the way to go.

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

No branches or pull requests

1 participant