'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'

@classmethod
def _encode_message(cls, message):

    if (message.magic == 0):
        msg = ''.join([struct.pack('>BB', message.magic, message.attributes), write_int_string(message.key), write_int_string(message.value)])
        crc = crc32(msg)
        msg = struct.pack(('>i%ds' % len(msg)), crc, msg)
    else:
        raise ProtocolError(('Unexpected    magic    number:    %d' % message.magic))
    return msg
