@classmethod<EOL><INDENT>def _encode_message(cls, message):<DEDENT>
if message.magic == <NUM_LIT:0>:<EOL><INDENT>msg = b'<STR_LIT>'.join([<EOL>struct.pack('<STR_LIT>', message.magic, message.attributes),<EOL>write_int_string(message.key),<EOL>write_int_string(message.value)<EOL>])<EOL>crc = crc32(msg)<EOL>msg = struct.pack('<STR_LIT>' % len(msg), crc, msg)<EOL><DEDENT>else:<EOL><INDENT>raise ProtocolError("<STR_LIT>" % message.magic)<EOL><DEDENT>return msg<EOL>
Encode a single message.

The magic number of a message is a format version number.
The only supported magic number right now is zero

Format
======
Message => Crc MagicByte Attributes Key Value
  Crc => int32
  MagicByte => int8
  Attributes => int8
  Key => bytes
  Value => bytes