The Wayback Machine - https://web.archive.org/web/20211006153558/https://github.com/segmentio/kafka-go/pull/160
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

Add ApiVersions request #160

Merged
merged 4 commits into from Jan 9, 2019
Merged

Conversation

@VictorDenisov
Copy link
Contributor

@VictorDenisov VictorDenisov commented Dec 17, 2018

I would like to merge this as a separate PR for easier review. I will need this change is implementing v2 message reader: #146
I'll be using this request right after connecting to kafka cluster in order to determine which fetch requests I'm allowed to send.
So far the plan is to implement fetch request v5. Fetch request v5 seems to have been introduced in kafka 0.11.0.0. And presumably this is the first version where server returns message sets in v2 format.
So, if fetch request v5 is available I'll be sending v5 otherwise v2.

Copy link
Contributor

@achille-roussel achille-roussel left a comment

Looking good overall, just left a couple of questions.

}

if errorCode != 0 {
return r, Error(errorCode)
Copy link
Contributor

@achille-roussel achille-roussel Jan 4, 2019

Should we return a nil []ApiVersion here? Or is there value in exposing a partial result?

Copy link
Contributor Author

@VictorDenisov VictorDenisov Jan 4, 2019

My approach was, - I'm giving you whatever I have just use it at your own discretion since there was an error. I can return nil here if you think it makes more sense.

Copy link
Contributor

@achille-roussel achille-roussel Jan 4, 2019

Up to you, I don't have strong feelings about it.

conn.go Outdated
var err error
c.apiVersions, err = c.ApiVersions()
if err != nil {
c.apiVersions = nil
Copy link
Contributor

@achille-roussel achille-roussel Jan 4, 2019

Should we put a default value here?

Copy link
Contributor Author

@VictorDenisov VictorDenisov Jan 4, 2019

I guess I can put the value that lists all the versions that the current implementation of kafka-go works with.

Copy link
Contributor

@achille-roussel achille-roussel Jan 4, 2019

Seems like it could help making good use of this field 👍

conn.go Outdated
@@ -71,6 +71,7 @@ type Conn struct {

// number of replica acks required when publishing to a partition
requiredAcks int32
apiVersions []ApiVersion
Copy link
Contributor

@achille-roussel achille-roussel Jan 4, 2019

Is there a guarantee on the ordering of the values here? I'm wondering how the lookups will work.

Copy link
Contributor Author

@VictorDenisov VictorDenisov Jan 4, 2019

I can check for ordering. But I just realized that for our purposes it, probably, makes more sense to put it in a map: map[api key]ApiVersion

Copy link
Contributor

@achille-roussel achille-roussel Jan 4, 2019

A map makes sense to me 👍

@VictorDenisov
Copy link
Contributor Author

@VictorDenisov VictorDenisov commented Jan 6, 2019

@achille-roussel, I addressed the comments.

@achille-roussel
Copy link
Contributor

@achille-roussel achille-roussel commented Jan 9, 2019

Looking good, thanks for adding this!

@achille-roussel achille-roussel merged commit 266d14d into segmentio:master Jan 9, 2019
@VictorDenisov VictorDenisov deleted the api_versions branch Jan 12, 2019
@stevevls stevevls mentioned this pull request Feb 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Linked issues

Successfully merging this pull request may close these issues.

None yet

2 participants