-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
feat: add brokers field to support set broker with the same host in kafka-logger plugin #7999
Conversation
f3a2f76
to
48d9379
Compare
apisix/plugins/kafka-logger.lua
Outdated
@@ -251,3 +284,4 @@ end | |||
|
|||
|
|||
return _M | |||
|
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.
Remove the empty line.
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.
Fixed.
| broker_list | object | True | | | List of Kafka brokers (nodes). | | ||
| broker_list | deprecated | True | | | Use `brokers` instead. List of Kafka brokers. (nodes). | | ||
| brokers | array | True | | | List of Kafka brokers (nodes). | | ||
| brokers.host | string | True | | | The host of Kafka broker | |
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.
| brokers.host | string | True | | | The host of Kafka broker | | |
| brokers.host | string | True | | | The host of Kafka broker, e.g., `192.168.1.1`. | |
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.
Fixed.
@@ -37,7 +37,10 @@ It might take some time to receive the log data. It will be automatically sent a | |||
|
|||
| Name | Type | Required | Default | Valid values | Description | | |||
| ---------------------- | ------- | -------- | -------------- | --------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | | |||
| broker_list | object | True | | | List of Kafka brokers (nodes). | | |||
| broker_list | deprecated | True | | | Use `brokers` instead. List of Kafka brokers. (nodes). | |
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.
It would be better to put the "deprecated" in the Description instead of the Type?
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.
Oh. I refer to the docs of https://github.com/apache/apisix/blob/master/docs/en/latest/plugins/clickhouse-logger.md#attributes.
Let me fix it.
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.
Fixed.
| broker_list | object | True | | | List of Kafka brokers (nodes). | | ||
| broker_list | deprecated | True | | | Use `brokers` instead. List of Kafka brokers. (nodes). | | ||
| brokers | array | True | | | List of Kafka brokers (nodes). | | ||
| brokers.host | string | True | | | The host of Kafka broker, e.g, `192.168.1.1`. | |
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 to update the Chinese version?
CC @SylviaBABY
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 to update the Chinese version? CC @SylviaBABY
I think we need to update the CN version. But you can merge this first. I'll update the CN version depending on this part later
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.
Let me update the Chinese version.
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.
Fixed.
apisix/plugins/kafka-logger.lua
Outdated
@@ -199,15 +225,24 @@ function _M.log(conf, ctx) | |||
end | |||
|
|||
-- reuse producer via lrucache to avoid unbalanced partitions of messages in kafka | |||
local broker_list = core.table.new(core.table.nkeys(conf.broker_list), 0) | |||
local length = conf.broker_list and core.table.nkeys(conf.broker_list) or #conf.brokers |
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.
Just FYI: if we don't need to rewrite the content of table, we can use core.table.clone instead of alloc + insert in loop
.
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.
Let me update it.
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.
Thanks for the remind. Improved.
Co-authored-by: Sylvia <39793568+SylviaBABY@users.noreply.github.com>
…afka-logger plugin (apache#7999) Co-authored-by: Sylvia <39793568+SylviaBABY@users.noreply.github.com>
Description
Fix #7998
Because the key in the JSON object should be different.
And the original design we use map to store the broker list, so we can't create a broker with the same host.
Now, I add a new filed
brokers
(It's an array type), then we can create brokers with the same host.Checklist