How will we parse the api_version if it’s negative as u8 only represent the positive values.
Depends on the language, but it doesn’t have to be u8, as, according to kafka documentation, api_ver comes as an int16, which is stated here: Apache Kafka
It doesn’t mean that we can’t receive some garbage in request. Then it comes to error handle’ing, which we are doing in the exercise. My solution i.e. implements a match statement for api_ver, which creates correct response if api ver contains anything between 0 and 4 inclusively and for everything else we create an error response.
In case we cannot even parse api_ver, we would also send error response
Closing this thread due to inactivity. If you still need assistance, feel free to reopen or start a new discussion!
take my code for example
messageSize := binary.BigEndian.Uint32( request[0:4] ) // request message size
binary.BigEndian.PutUint32(response[0:4], uint32(messageSize)) // 4 Byte
- in my code which cannot pass the test , here I falsely set the response message size as the request message size, which cause the tester
read the wrong number of bytes
from connection; - so I later set the response size to a fixed value
19
correctly ; - and you can also set the
response_header_size
according to your response structure
This topic was automatically closed 5 days after the last reply. New replies are no longer allowed.