You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Using a TableView with a JSONSchema, the Get method should return a instance of the Go type provided via the TableViewOptions.SchemaValueType field.
Actual behavior
The type returned from the Get method is map[string]interface{} (and I presume it could also be []interface{}, string, float64, bool or nil depending on the raw JSON).
Steps to reproduce
The following test reproduces the issue, where exampleSchemaDef, testJSON, lookupURL and newTopicName are defined in the pulsar package test files.
I believe I have a fix for this. Once it has been reviewed by my colleagues I'll open a PR in this repo. I expect that will be later today or tomorrow.
Fixes#1132
### Motivation
Fix issue #1132 - using JSONSchema with TableView
### Modifications
- Set a concrete type in the `payload` variable before JSON-unmarshalling into that variable. This allows the JSON package to identify and use the type rather than seeing it as `interface{}`.
- Use `reflect.Indirect(payload).Interface()` when storing the payload and passing it to listeners to remove the pointer from `reflect.New`.
- Add test coverage for `TableView.Get` covering all supported schema types.
- Add test coverage for `TableView.ForEachAndListen` for JSONSchema.
Additional minor changes. They didn't seem worth their own MRs but I'm happy to split them out if that's better.
- Correct typo in comments on `TableView.ForEach` and `TableView.ForEachAndListen` interface methods.
- Correct `TableView.ForEachAndListen` comment to clarify that it continues to call the given action on future messages.
- Correct formatting directive (`%w` -> `%v`) in error log `tv.logger.Errorf("msg.GetSchemaValue() failed with %v; msg is %v", err, msg)`. (This indirectly calls `fmt.Sprintf` in logrus which doesn't support `%w`).
Expected behavior
Using a TableView with a JSONSchema, the
Get
method should return a instance of the Go type provided via theTableViewOptions.SchemaValueType
field.Actual behavior
The type returned from the
Get
method ismap[string]interface{}
(and I presume it could also be[]interface{}
,string
,float64
,bool
ornil
depending on the raw JSON).Steps to reproduce
The following test reproduces the issue, where
exampleSchemaDef
,testJSON
,lookupURL
andnewTopicName
are defined in thepulsar
package test files.System configuration
Pulsar version: 3.1.0
The text was updated successfully, but these errors were encountered: