def _write_header(self, buff, api_version=0, correlation_id=0):
"""Write the header for an outgoing message.
:param buff: The buffer into which to write the header
:type buff: buffer
:param api_version: The "kafka api version id", used for feature flagging
:type api_version: int
:param correlation_id: This is a user-supplied integer. It will be
passed back in the response by the server, unmodified. It is useful
for matching request and response between the client and server.
:type correlation_id: int
"""
fmt = '!ihhih%ds' % len(self.CLIENT_ID)
struct.pack_into(fmt, buff, 0,
len(buff) - 4, # msglen excludes this int
self.API_KEY,
api_version,
correlation_id,
len(self.CLIENT_ID),
self.CLIENT_ID)
评论列表
文章目录