Improve the default JSON rule parsers in ext/datasource package #191
Labels
area/data-source
Issues or PRs related to data-source extension
good first issue
Good for newcomers
kind/enhancement
Category issues or PRs related to enhancement
Milestone
Issue Description
Type: improvement
Describe what feature you want
The default JSON rule parsers in
ext/datasource
package could be improved. In current implementation, even if the JSON itself is not an array of flow rule entities, emptyFlowRule
might be generated:sentinel-golang/ext/datasource/helper.go
Lines 32 to 51 in 1f1c71b
Though the empty entity will be filtered out when pumping it to downstream consumers, the creation of the "invalid" entity seems useless. In addition, it might be better to leverage the unified quotes of the fields (aka.
json:"xxx"
) to parse the object instead of writing the logic manually.The naming could be improved as well. For example:
FlowRulesJsonConverter
can beFlowRuleJsonArrayParser
or other better.Additional context
Add any other context or screenshots about the feature request here.
The text was updated successfully, but these errors were encountered: