Tomilla opened a new pull request, #1087:
URL: https://github.com/apache/rocketmq-client-go/pull/1087
## What is the purpose of the change
Create Topic with optional argument:
- broker address(current implement is required argument): direct invoke
`createTopic` API with address
- broker name: in first, client will call `getBrokerClusterInfo`, then
resolve name to address, then invoke API
- nothing: like broker name case, but it will apply `createTopic` on all
addresses that `getBrokerClusterInfo` returned.
## Brief changelog
1. implement `GetBrokerClusterInfo` of Admin interface. in the meanwhile,
there are integer type keys in RocketMQ Java Server response of
`GetBrokerClusterInfo`, Golang JSON library cannot unmarshal them directly. So
I fixed the JSON didn't conform to the JSON specification (JSON keys should
always be strings, don't use int as a key).
https://github.com/apache/rocketmq-client-go/blob/7eedaf948c6076c716972724782f4837e1f9caa6/admin/admin.go#L39
2. introduce another `CreateTopic` implementation like sarama, without
`brokerAddr` as input.
https://github.com/apache/rocketmq-client-go/blob/7eedaf948c6076c716972724782f4837e1f9caa6/admin/admin.go#L158
3. add optional flag for `createTopic` to avoid override same name topic
configuration. for back compatibility, it is false by default.
## Verifying this change
I've update the `examples/admin/topic/main.go` file, which demonstrates all
new features such as:
- get broker cluster info;
- create topic without broker address;
- create topic with "NotOverride" check.
furthermore, I also wrote UnitTest and BenchmarkTest for JSON integer key
rectify function.
Related to https://github.com/apache/rocketmq/issues/3369
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]