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

Improve Selector usability #726

Merged
merged 1 commit into from
Mar 4, 2021
Merged

Improve Selector usability #726

merged 1 commit into from
Mar 4, 2021

Conversation

mtdowling
Copy link
Member

This commit improves the usability of Selectors by adding new methods to
the Selector interface and by deprecating its runner functionality. The
new methods include methods to stream matching shapes, stream matches,
and consume matches. Streaming matches and shapes requires a minimal
amount of buffering, and they provide the ability to more easily perform
checks like determine if any shapes in a model match a selector. If all
matching shapes are necessary, calling select is preferred. If consuming
matches can be done in a way that is push-based (e.g., writing to CLI
output), then using consumeMatches is preferred to matches.

The previous runner() method of Selector is now deprecated and just
delegates calls back to the Selector. runner() was initially intended to
allow for the customization of the environment in which a selector is
executed, but this design turned out to be unnecessary, and as such, the
need to create a runner and use a kind of builder interface to use
Selectors made them awkward to work with for no benefit.

A final change is made to implement an IdentitySelector to optimize
matching all shapes in a model.

Issue #, if available:

Description of changes:

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.

This commit improves the usability of Selectors by adding new methods to
the Selector interface and by deprecating its runner functionality. The
new methods include methods to stream matching shapes, stream matches,
and consume matches. Streaming matches and shapes requires a minimal
amount of buffering, and they provide the ability to more easily perform
checks like determine if any shapes in a model match a selector. If all
matching shapes are necessary, calling select is preferred. If consuming
matches can be done in a way that is push-based (e.g., writing to CLI
output), then using consumeMatches is preferred to matches.

The previous runner() method of Selector is now deprecated and just
delegates calls back to the Selector. runner() was initially intended to
allow for the customization of the environment in which a selector is
executed, but this design turned out to be unnecessary, and as such, the
need to create a runner and use a kind of builder interface to use
Selectors made them awkward to work with for no benefit.

A final change is made to implement an IdentitySelector to optimize
matching all shapes in a model.
@mtdowling mtdowling force-pushed the selector-usability branch from b799315 to 6f6f006 Compare March 3, 2021 20:56
@mtdowling mtdowling requested a review from kstich March 3, 2021 20:56
@mtdowling mtdowling merged commit 4d98734 into main Mar 4, 2021
@mtdowling mtdowling deleted the selector-usability branch April 21, 2021 05:00
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.

2 participants