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(jq): parse input early and reuse filter instance #44

Merged
merged 1 commit into from
Nov 28, 2024

Conversation

flrgh
Copy link
Collaborator

@flrgh flrgh commented Nov 27, 2024

This moves filter compilation from NodeFactory::new_node() into NodeFactory::new_config(). Now we have input validation and filter compilation in on_configure instead of in the request path.

We don't need an owned j[a]q filter object to execute it, so instead of creating a new instance in NodeFactory::new_node(), we're just using std::rc::Rc to maintain a shared reference.

Making these changes effectively removed the differences between the Jq and JqConfig structs, so I just removed JqConfig and implemented NodeConfig for Rc<Jq> instead.

Haven't really looked into the perf implications of nested pointers (Box<Rc<Jq>>) yet (I feel like there's certainly a type system way around this), but whatever it is I'm sure it's still better than what the code was doing prior.

@flrgh flrgh requested a review from hishamhm November 27, 2024 20:58
This moves filter compilation from NodeFactory::new_node() into
NodeFactory::new_config(). This gives us earlier feedback on invalid
filter string user input and moves the costly filter compilation step
out of the request path.

We don't need an owned j[a]q filter object to execute it, so instead of
creating a new instance in NodeFactory::new_node(), we're just using
std::rc::Rc to maintain a shared reference.

Making these changes effectively removed the differences between the Jq
and JqConfig structs, so I just removed JqConfig and implemented
NodeConfig for Rc<Jq> instead.
@hishamhm hishamhm merged commit 93f2827 into main Nov 28, 2024
6 checks passed
@hishamhm hishamhm deleted the chore/jq-filter-reuse branch November 28, 2024 18:29
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