You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@rocketmq.apache.org by GitBox <gi...@apache.org> on 2022/08/17 08:46:20 UTC

[GitHub] [rocketmq-client-go] yuz10 opened a new pull request, #846: [ISSUE #845] support standard json

yuz10 opened a new pull request, #846:
URL: https://github.com/apache/rocketmq-client-go/pull/846

   ## What is the purpose of the change
   
   #845
   
   because  https://github.com/apache/rocketmq/pull/4432  change route info to standard json such as:
   `{"brokerDatas":[{"brokerAddrs":{"0":"127.0.0.1:10911"}]}`
   the old is:
   `{"brokerDatas":[{"brokerAddrs":{0:"127.0.0.1:10911"}]}`
   
   ## Brief changelog
   
   XX
   
   ## Verifying this change
   
   XXXX
   
   Follow this checklist to help us incorporate your contribution quickly and easily. Notice, `it would be helpful if you could finish the following 5 checklist(the last one is not necessary)before request the community to review your PR`.
   
   - [x] Make sure there is a [Github issue](https://github.com/apache/rocketmq/issues) filed for the change (usually before you start working on it). Trivial changes like typos do not require a Github issue. Your pull request should address just this issue, without pulling in other changes - one PR resolves one issue. 
   - [x] Format the pull request title like `[ISSUE #123] Fix UnknownException when host config not exist`. Each commit in the pull request should have a meaningful subject line and body.
   - [x] Write a pull request description that is detailed enough to understand what the pull request does, how, and why.
   - [x] Write necessary unit-test(over 80% coverage) to verify your logic correction, more mock a little better when a cross-module dependency exists.
   - [ ] If this contribution is large, please file an [Apache Individual Contributor License Agreement](http://www.apache.org/licenses/#clas).
   


-- 
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: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq-client-go] ShannonDing closed pull request #846: [ISSUE #845] support standard json

Posted by GitBox <gi...@apache.org>.
ShannonDing closed pull request #846: [ISSUE #845] support standard json
URL: https://github.com/apache/rocketmq-client-go/pull/846


-- 
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: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq-client-go] lizhanhui commented on pull request #846: [ISSUE #845] support standard json

Posted by GitBox <gi...@apache.org>.
lizhanhui commented on PR #846:
URL: https://github.com/apache/rocketmq-client-go/pull/846#issuecomment-1158419795

   Is it possible to change the deserialization workflow as follows?
   1.  Attempt to parse the response JSON using standard [go JSON library](http://golang.org/pkg/encoding/json/);
   2. Check and catch potential errors, fallback to manual parsing if invalid contents are found;


-- 
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: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq-client-go] lizhanhui commented on pull request #846: [ISSUE #845] support standard json

Posted by GitBox <gi...@apache.org>.
lizhanhui commented on PR #846:
URL: https://github.com/apache/rocketmq-client-go/pull/846#issuecomment-1217700175

   @yuz10 I am assuming this pull request works for both standard and illegal JSON responses. Right?


-- 
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: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq-client-go] ShannonDing closed pull request #846: [ISSUE #845] support standard json

Posted by GitBox <gi...@apache.org>.
ShannonDing closed pull request #846: [ISSUE #845] support standard json
URL: https://github.com/apache/rocketmq-client-go/pull/846


-- 
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: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq-client-go] yuz10 commented on a diff in pull request #846: [ISSUE #845] support standard json

Posted by GitBox <gi...@apache.org>.
yuz10 commented on code in PR #846:
URL: https://github.com/apache/rocketmq-client-go/pull/846#discussion_r899736709


##########
internal/route.go:
##########
@@ -558,7 +558,8 @@ func (routeData *TopicRouteData) decode(data string) error {
 				if i < 0 {
 					continue
 				}
-				id, _ := strconv.ParseInt(str[0:i], 10, 64)
+				brokerId := strings.ReplaceAll(str[0:i], "\"", "")
+				id, _ := strconv.ParseInt(brokerId, 10, 64)

Review Comment:
   I am afraid we cant use the standard way because the json is not standard, the change have already handled both stardard hand non-stardard formats



-- 
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: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq-client-go] ShannonDing merged pull request #846: [ISSUE #845] support standard json

Posted by GitBox <gi...@apache.org>.
ShannonDing merged PR #846:
URL: https://github.com/apache/rocketmq-client-go/pull/846


-- 
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: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq-client-go] zhouxinyu commented on a diff in pull request #846: [ISSUE #845] support standard json

Posted by GitBox <gi...@apache.org>.
zhouxinyu commented on code in PR #846:
URL: https://github.com/apache/rocketmq-client-go/pull/846#discussion_r899723643


##########
internal/route.go:
##########
@@ -558,7 +558,8 @@ func (routeData *TopicRouteData) decode(data string) error {
 				if i < 0 {
 					continue
 				}
-				id, _ := strconv.ParseInt(str[0:i], 10, 64)
+				brokerId := strings.ReplaceAll(str[0:i], "\"", "")
+				id, _ := strconv.ParseInt(brokerId, 10, 64)

Review Comment:
   Can we deserialize JSON string in a standard way? Make the SDK could handle both the two formats.



-- 
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: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


[GitHub] [rocketmq-client-go] yuz10 commented on pull request #846: [ISSUE #845] support standard json

Posted by GitBox <gi...@apache.org>.
yuz10 commented on PR #846:
URL: https://github.com/apache/rocketmq-client-go/pull/846#issuecomment-1158458175

   > Is it possible to change the deserialization workflow as follows?
   > 
   > 1. Attempt to parse the response JSON using standard [go JSON library](http://golang.org/pkg/encoding/json/);
   > 2. Check and catch potential errors, fallback to manual parsing if invalid contents are found;
   
   I think it is worthless to Attempt the first time to parse standard json, because in most case it will fail


-- 
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: dev-unsubscribe@rocketmq.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org