'Init the connection to the Kafka server.'

def init(self):

    if (not self.export_enable):
        return None
    server_uri = '{}:{}'.format(self.host, self.port)
    try:
        s = KafkaProducer(bootstrap_servers=server_uri, value_serializer=(lambda v: json.dumps(v).encode('utf-8')), compression_type=self.compression)
    except Exception as e:
        logger.critical(('Cannot    connect    to    Kafka    server    %s    (%s)' % (server_uri, e)))
        sys.exit(2)
    else:
        logger.info(('Connected    to    the    Kafka    server    %s' % server_uri))
    return s
