-
Notifications
You must be signed in to change notification settings - Fork 236
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: add the XPath/RegEx Data Extractor and Expression Evaluation for HTTP Probe #192
Conversation
Codecov Report
@@ Coverage Diff @@
## main #192 +/- ##
==========================================
+ Coverage 93.92% 94.34% +0.41%
==========================================
Files 46 49 +3
Lines 3655 3926 +271
==========================================
+ Hits 3433 3704 +271
Misses 155 155
Partials 67 67
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
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.
IMHO, If I implemented the feature, I would prefer to splitting the Evaluator and Configuration into different objects, and the Evaluator object has only one in the global, configuration object for each HTTP prober.
Just a different design style
return false, err | ||
} | ||
|
||
expression, err := govaluate.NewEvaluableExpressionWithFunctions(e.Expression, e.EvalFuncs) |
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.
The result of govaluate.NewEvaluableExpressionWithFunctions(e.Expression, e.EvalFuncs)
can be cached which should minor improve performance. [1]
[1] https://github.com/Knetic/govaluate/blob/master/benchmarks_test.go#L104-L114
I considered separating the Evaluator and Configuration, but they are the exactly same object which would introduce the duplication code we have to maintain their consistency. And there is a Variable object inside, so finally, just use one struct for both of them. If we only use one global Evaluator object for all HTTP probers, then we have to manage the different configurations for different HTTP probers, as they would have different document format(xml/html/json/txt) and different expressions. And this also would introduce multiple threads complexity. I prefer to have the dedicated Evaluator object for each HTTP probers. |
try to support the following expression evaluation.
or simple one
Note:
x_str()
,x_int()
,x_float()
,x_time()
,x_bool()
,x_duration()
are the functions can extract the data by using XPath or Regex expressionPlease focus on those files