- 
                Notifications
    
You must be signed in to change notification settings  - Fork 3
 
Shared utilities to handle VRL expressions & some other improvements #540
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
base: main
Are you sure you want to change the base?
Conversation
      
        
              This comment was marked as outdated.
        
        
      
    
  This comment was marked as outdated.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request introduces a new Expression type to centralize VRL expression handling, which is a great improvement for maintainability. The new type encapsulates VRL compilation and execution, removing duplicated logic from various parts of the executor. My review focuses on performance improvements for this new type, in line with the repository's style guide.
          
✅ 
 | 
    
| 
           🐋 This PR was built and pushed to the following Docker images: Image Names:  Platforms:  Image Tags:  Docker metadata{
"buildx.build.ref": "builder-0c044f54-0e2b-44ec-bfea-e82a686617ee/builder-0c044f54-0e2b-44ec-bfea-e82a686617ee0/y48xbq6zugd2ihjm2u5orc7zd",
"containerimage.descriptor": {
  "mediaType": "application/vnd.oci.image.index.v1+json",
  "digest": "sha256:bddf9468aac1eed8ed60e9aafe2961dd07f839d788b19fcc1f45309bcf028c53",
  "size": 1609
},
"containerimage.digest": "sha256:bddf9468aac1eed8ed60e9aafe2961dd07f839d788b19fcc1f45309bcf028c53",
"image.name": "ghcr.io/graphql-hive/router:pr-540,ghcr.io/graphql-hive/router:sha-a7217d0"
} | 
    
| static VRL_FUNCTIONS: Lazy<Vec<Box<dyn Function>>> = Lazy::new(vrl_build_functions); | ||
| static VRL_TIMEZONE: Lazy<VrlTimeZone> = Lazy::new(VrlTimeZone::default); | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's not do it this way, where we centralize the function building.
Yeah, right now we pass all functions that vrl provides, but if we ever want to add one made by us or filter some, for certain expressions, we would have to opt out and, we won't be able to do it without basically reverting your changes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just didn't want to copy/paste the same logic again like we did 3 different places before. How do you think I should do that instead?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can create a function and reuse it. If we ever want to opt-out, we either slightly refactor it or duplicate.
if you move this logic to the config crate then we’re not able to do those small adjustments in future
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks better now?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, it's much better now. Thanks
If we ever want to use different set of function, we can now do:
compile_expression(expression, Some(fns))
and add pre-built functions anywhere in code, where it makes sense.
Expression type to handle VRL in one place| /// An expression that must evaluate to a boolean. If true, the label will be applied. | ||
| expression: String, | ||
| }, | ||
| Expression { expression: String }, | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
original comment is missing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reverted 👍
        
          
                lib/executor/Cargo.toml
              
                Outdated
          
        
      | indexmap = "2.10.0" | ||
| bumpalo = "3.19.0" | ||
| once_cell = "1.21.3" | ||
| schemars = "1.0.4" | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you sure we need schemars in executor?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Removed 👍
2644a55    to
    128b10a      
    Compare
  
    128b10a    to
    766bd0e      
    Compare
  
    Removed `pool_idle_timeout_seconds` from `traffic_shaping` and replaced it with `pool_idle_timeout` using duration format.
4cffb36    to
    c709bec      
    Compare
  
    
Removed
pool_idle_timeout_secondsfromtraffic_shaping, instead usepool_idle_timeoutwith duration format.Related documentation changes PR -> graphql-hive/console#7207
Created some helper functions to deduplicate the code to compile and resolve VRL expressions