brbzull0 commented on PR #9599: URL: https://github.com/apache/trafficserver/pull/9599#issuecomment-1523796522
> I've been pondering this and I don't think this is going to suffice. For instance, suppose `field1` is an array - does the plugin have to parse that independently? > > A similar alternative we may want to look at is SAX style parsing. This has proved very successful in practice for both XML and JSON. It is event driven (which makes it similar to this) but has more events to handle nested data. Here is [one example](https://zserge.com/jsmn/) written in C. Since YAML is data equivalent to JSON we could ~steal~ pay homage to the API in a rather direct way. > > The bigger question is, how would this be used in practice, say by `conf_remap`? Once the value is parsed, how would it be used? If the configuration is structured then that structure would need to be passed to the core. How would that be done? If by (effectively) YAML text, there's no use in the plugin understanding that YAML, it's just blindly forwarding. Is the expectation that the callback points are roots of those values? So, if you check [conf_remap](https://github.com/apache/trafficserver/blob/7b34a528bd7ac272be76d40dc469f225b6cf416f/plugins/conf_remap/conf_remap.cc#L127-L254) plugin you will see that the plugin parses the records.config(input files) style file inside the plugin(copy and paste from the old records.config parser), then for each record it will add an element into an internal table which then will be used to override a configuration records when a remap is called. The idea is to support the very same but instead reading YAML files. I wanted to avoid to copy/paste the same parser as we have for records.yaml in ATS which flatten the YAML node into a record style variable(name.for.the.config). Each node gets flattened inside ATS using the same function as we have for records.yaml and then it calls the callback function with the node and the value, conf_remap then does the same as before where it stores the variable and the new value. I have this in my own [branch](https://github.com/brbzull0/trafficserver/commit/a5b0c843469ce22d9f02a120ae28232cca16d9eb) if you want to have a look at this with an example. This code is the updated conf_remap which reads YAML files as input files. ``` map /test http://127.0.0.1/ @plugin=conf_remap.so @pparam=variables.yaml ``` -- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. To unsubscribe, e-mail: [email protected] For queries about this service, please contact Infrastructure at: [email protected]
