Example #1
0
    def start(self, callback):
        """Create everything necessary to receive a message"""

        logger.debug('Starting RabbitMQ Subscriber')
        self._exchange = self._create_exchange()
        self._queue = self._create_queue()
        self._callback = callback
Example #2
0
    def _connect(self):
        """Create a RabbitMQ connection"""

        logger.debug('Connecting with RabbitMQ')
        connection = kombu.Connection(**self.config.get('connection'))
        connection.ensure_connection()
        return connection
Example #3
0
    def _connect(self):
        """Create a RabbitMQ connection"""

        logger.debug('Connecting with RabbitMQ')
        connection = kombu.Connection(**self.config.get('connection'))
        connection.ensure_connection()
        return connection
Example #4
0
    def _create_exchange(self):
        """Create a RabbitMQ exchange"""

        logger.debug('Creating RabbitMQ Exchange')
        exchange = kombu.Exchange(
            **self.config.get('exchange'))(self.connection)
        exchange.declare()
        return exchange
Example #5
0
    def _create_exchange(self):
        """Create a RabbitMQ exchange"""

        logger.debug('Creating RabbitMQ Exchange')
        exchange = kombu.Exchange(**self.config.get('exchange'))(
            self.connection)
        exchange.declare()
        return exchange
Example #6
0
    def _create_queue(self):
        """Create a RabbitMQ queue"""

        if not self.config.get('queue').get('name'):
            self.config['queue']['name'] = socket.gethostname()

        logger.debug('Creating RabbitMQ Queue')
        queue = kombu.Queue(exchange=self._exchange,
                            **self.config.get('queue'))(self.connection)
        queue.declare()
        return queue
Example #7
0
    def _create_queue(self):
        """Create a RabbitMQ queue"""

        if not self.config.get('queue').get('name'):
            self.config['queue']['name'] = socket.gethostname()

        logger.debug('Creating RabbitMQ Queue')
        queue = kombu.Queue(exchange=self._exchange,
                            **self.config.get('queue'))(self.connection)
        queue.declare()
        return queue
Example #8
0
    def write(self, point):
        """Write to InfluxDB
        point is a tuple that contain (DATE, VALUE)
        """

        host = "{0}-{1}".format(self.name, socket.gethostname())
        json_body = [{
            "measurement": self.name,
            "tags": {
                "host": host,
            },
            "time": point[0],
            "fields": {
                "value": point[1]
            }
        }]

        logger.debug('Write on InfluxDB: {0}. point: {1}'.format(host, point))
        self.client.write_points(json_body)
Example #9
0
    def write(self, point):
        """Write to InfluxDB
        point is a tuple that contain (DATE, VALUE)
        """

        host = "{0}-{1}".format(self.name, socket.gethostname())
        json_body = [{
            "measurement": self.name,
            "tags": {
                "host": host,
            },
            "time": point[0],
            "fields": {
                "value": point[1]
            }}]

        logger.debug('Write on InfluxDB: {0}. point: {1}'.format(
            host, point))
        self.client.write_points(json_body)
Example #10
0
    def __init__(self, name, config, *args, **kwargs):

        logger.debug('Starting InfluxDB client')
        self.client = InfluxDBClient(**config.get('client'))
        self.name = name
Example #11
0
    def __init__(self, name, config, *args, **kwargs):

        logger.debug('Starting InfluxDB client')
        self.client = InfluxDBClient(**config.get('client'))
        self.name = name
Example #12
0
    def start(self):
        """Create everything necessary to send a message"""

        logger.debug('Starting RabbitMQ Publisher')
        self._exchange = self._create_exchange()
        self._producer = self._create_producer()