-
Notifications
You must be signed in to change notification settings - Fork 448
Dynamic datasource framework init #73
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
Conversation
f031332 to
8554653
Compare
| if src == nil { | ||
| return nil | ||
| } | ||
| rs := gjson.ParseBytes(src).Array() |
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.
This is a little problem: what should I do if the data souce is a file in toml format?
| "github.com/tidwall/gjson" | ||
| ) | ||
|
|
||
| func SystemRulesConvert(src []byte) interface{} { |
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.
[]byte looks a little strange, how about io.Reader?
| return errors.New(fmt.Sprintf("Invalid parameters: data:%+v", data)) | ||
| } | ||
| val, ok := data.([]*system.SystemRule) | ||
| if !ok { |
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.
Do we need compare the data in cache with the new data like the Java design? Or update the value in cache directly?
| return ds | ||
| } | ||
|
|
||
| func (ds *FileDataSource) listen() { |
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.
As you add two function for type DataSource interface, all the specific datasource should implement it.
| //} | ||
|
|
||
| func TestNewFileDataSource_SystemRule(t *testing.T) { | ||
| ds := FileDataSourceStarter("../../tests/testdata/extension/refreshable_file/SystemRule.json", ext.NewSystemRulesHandle()) |
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.
For a better understanding of the frame, I think should declare ds with DataSource type.
7e03d5f to
2fff20e
Compare
extension/property.go
Outdated
| realSrc, err := json.Marshal(realProperty) | ||
| if err!=nil { | ||
| logger.Warnf("Fail to marshal property source, err:%+v.", err) | ||
| } | ||
| isConsistent := h.isPropertyConsistent(realSrc) |
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.
Maybe we can compare the parsed entity directly, rather than convert it to JSON string then compare.
extension/property.go
Outdated
| type DefaultPropertyHandler struct { | ||
| lastUpdateProperty interface{} | ||
|
|
||
| Convert PropertyConvert |
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.
Make it private and access it with the getter method?
f6c1bcd to
d7d6a6c
Compare
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.
LGTM
|
Nice work. Thanks! |
Describe what this PR does / why we need it
Does this pull request fix one issue?
Will define the dynamic data source extension framework.
Describe how you did it
Describe how to verify it
Special notes for reviews