Skip to content

feat: add brokers field to support set broker with the same host in kafka-logger plugin#7999

Merged
spacewander merged 9 commits into
apache:masterfrom
starsz:feat_support_broker_array
Oct 8, 2022
Merged

feat: add brokers field to support set broker with the same host in kafka-logger plugin#7999
spacewander merged 9 commits into
apache:masterfrom
starsz:feat_support_broker_array

Conversation

@starsz

@starsz starsz commented Sep 27, 2022

Copy link
Copy Markdown
Contributor

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

  • I have explained the need for this PR and the problem it solves
  • I have explained the changes or the new features added to this PR
  • I have added tests corresponding to this change
  • I have updated the documentation to reflect this change
  • I have verified that this change is backward compatible (If not, please discuss on the APISIX mailing list first)

@starsz
starsz force-pushed the feat_support_broker_array branch from f3a2f76 to 48d9379 Compare September 29, 2022 03:58
@starsz starsz changed the title feat: support set broker array in kafka-logger plugin feat: add brokers field to support set broker with the same host in kafka-logger plugin Sep 29, 2022
@starsz
starsz marked this pull request as ready for review September 29, 2022 07:55
Comment thread apisix/plugins/kafka-logger.lua Outdated


return _M

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove the empty line.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

Comment thread apisix/plugins/kafka-logger.lua
Comment thread docs/en/latest/plugins/kafka-logger.md Outdated
| 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 |

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
| brokers.host | string | True | | | The host of Kafka broker |
| brokers.host | string | True | | | The host of Kafka broker, e.g., `192.168.1.1`. |

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

Comment thread t/plugin/kafka-logger2.t
tokers
tokers previously approved these changes Sep 30, 2022
tzssangglass
tzssangglass previously approved these changes Sep 30, 2022
Comment thread docs/en/latest/plugins/kafka-logger.md Outdated
| 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). |

Copy link
Copy Markdown
Member

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?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Copy Markdown
Contributor Author

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`. |

Copy link
Copy Markdown
Member

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

Copy link
Copy Markdown
Member

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

Copy link
Copy Markdown
Contributor Author

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

Comment thread apisix/plugins/kafka-logger.lua Outdated

-- 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

Copy link
Copy Markdown
Member

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.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let me update it.

Copy link
Copy Markdown
Contributor Author

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.

@starsz
starsz dismissed stale reviews from tzssangglass and tokers via 2d8f189 September 30, 2022 07:20
Comment thread docs/zh/latest/plugins/kafka-logger.md Outdated
@spacewander
spacewander merged commit e9ec16f into apache:master Oct 8, 2022
@starsz
starsz deleted the feat_support_broker_array branch October 9, 2022 01:19
Liu-Junlin pushed a commit to Liu-Junlin/apisix that referenced this pull request Nov 4, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

feat: As a user, I want to set more than one broker in kafka-logger plugin, so that we can push message to them at a time

5 participants