-
Notifications
You must be signed in to change notification settings - Fork 28
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
incorrect implementation of CreateTopics specification #84
Comments
Wanted to confirm the Java behavior, and this is the underlying data structure used: ImplicitLinkedHashCollection. |
confirming that even in the latest kafka commit, topics are defined as
the |
i dont think anything in the wire protcol use maps the only collection seemed to be used is a list. the java implementation replaces that with a this is different from the behavior in this lib. |
This sounds like a problem! But assuming for a second that it does, I wonder how best to solve this. However, such an API would be quite error prone, we would need to manually check the length of the list before using it. Maybe what we want is: enum MapEntry<T> {
Single(T)
Duplicates(Box<[T]>)
}
impl MapEntry {
fn get(&self) -> Result<T, Vec<T>> {
match self {
MapEntry::Single(x) => Ok(x),
MapEntry::Duplicates(x) => Err(x),
}
}
} And then use Actually, maybe we want to simplify that to: And this all assumes that it is always an error to have a duplicate map key which might not be true in some cases... |
I think short term the best option would be to make a thin wrapper around a Long term you could think about forking |
I think we should go for the easy/ugly |
Thinking about the ways in which the protocol is actually used I think that replacing IndexMap with Vec might actually be the best for performance. Since the kafka protocol very rarely has us request data that we dont care about, when processing a response most of the time we just call
|
@rukai I think it would still be good to use a wrapper around Vec (with zero-cost conversions) so that it can be changed in a backwards compatible way, and have additional methods provided, like get by key. |
the current implementation uses a map with topic names as keys:
however, this prevents requests which have duplicate topic names.
so this test for example will fail here:
https://github.com/segmentio/kafka-go/blob/a8e5eabf4a90025a4ad2c28e929324d18db21103/createtopics_test.go#L77
it creates 3 topics, out of which 2 are duplicate.
it then expects an
InvalidRequest
error code for the duplicated topic and neither of the duplicated topics is created.however, due to current implementation, the server will never receive the duplicate topic, since the map will just end up replacing the data of the duplicated topic, which will make server implementations create the topic instead of returning an error.
The text was updated successfully, but these errors were encountered: