Skip to content
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

fix: api_version #152

Closed
wants to merge 1 commit into from
Closed

fix: api_version #152

wants to merge 1 commit into from

Conversation

DG-Wangtao
Copy link
Contributor

Hi @doujiang24 ,
I think I made a mistake in #137 while trying to resolve #135, so I'm creating a new pull request to fix it.

@doujiang24
Copy link
Owner

could you please describe the bug in detail? I'm not sure I'm catching up with you.

@DG-Wangtao
Copy link
Contributor Author

if not self.api_version then
        version = self.api_version 
end

First of all, the code means that we use self.api_version as version if we **not** set self.api_version manually. It's obvious an error and it should be we use self.api_version as version only if we set self.api_version.

Secondly,API_VERSION_V0 is useed as default value of self.api_version :

api_version = opts.api_version or API_VERSION_V0,
The self.api_version will be API_VERSION_V0 if we not set manually.

So I implement it as "use self.api_version as version if it's set manually":

if not (self.api_version == API_VERSION_V0) then
        version = self.api_version 
end

@doujiang24
Copy link
Owner

okay, I see the problem. but I'm afraid this may not be a proper fix.

actually, we hope to use API_VERSION_V1 as the default api_version here, only for producer send, right?
this looks a bit weird, we use the different default values in different places.

I think the proper way is, you specify the api_version in your upper level code, while init the producer.

Or, if you think API_VERSION_V0 is not worthing to support, we could turn the default value to API_VERSION_V1 while init producer.
and you need to approve it, i.e. the versions of kafka that support API_VERSION_V0 are too old.

@DG-Wangtao
Copy link
Contributor Author

  • API_VERSION_V1 is used as default before my last pr: fix: api_version not used while producing to kafka #149
  • I test the API_VERSION_V0 and got an error that 2023/04/13 04:28:47 [error] 1127#0: *147 [lua] producer.lua:272: buffered messages send to kafka err: closed, retryable: true, topic: audit-log, partition_id: 1, length: 5, context: ngx.timer, maybe it is the same error with the ci test failure in Update producer.lua #137.
  • API_VERSION_V0 maybe not work in some kafka version, at least not work in your ci test env.
  • So I think we should use API_VERSION_V1 as default value , or it's maybe a better way to just use API_VERSION_V1 in
    api_version = opts.api_version or API_VERSION_V0,

@doujiang24
Copy link
Owner

@DG-Wangtao Thanks for your clearify.

I think the proper way is, you specify the api_version in your upper level code, while init the producer.

does this work for you?

@DG-Wangtao
Copy link
Contributor Author

DG-Wangtao commented Apr 14, 2023

yes. it works well if I set api_version while init the producer.

I think use API_VERSION_V1 as default value would be better, thus I create a new branch here:

I you agree with this idea I will update this pull request.

@DG-Wangtao
Copy link
Contributor Author

DG-Wangtao commented Oct 25, 2023

Hi @doujiang24, I think this pull request is ready to merge, do you have any concerns?

@doujiang24
Copy link
Owner

@DG-Wangtao Sorry for the late.
Seems this new branch is better, can it pass the CI?
master...DG-Wangtao:lua-resty-kafka:fix/api-version

@doujiang24
Copy link
Owner

the code logical in the current patch looks weird, if the new branch passes the CI, I prefer the new branch.

@DG-Wangtao DG-Wangtao mentioned this pull request Oct 26, 2023
@DG-Wangtao
Copy link
Contributor Author

DG-Wangtao commented Oct 26, 2023

Yes, logical in branch https://github.com/DG-Wangtao/lua-resty-kafka/tree/fix/api-version is a better way, which has been running in my env for a long time. I created a new pull request from the branch here #160 an passed the CI.

@doujiang24 Thanks for your work, I'm closing this pull request.

@DG-Wangtao DG-Wangtao closed this Oct 26, 2023
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.

client 生产消息未携带时间戳
2 participants