Пример #1
0
def get_listener():
    global _listener
    if not _listener:
        with Connection(transport_utils.get_messaging_urls()) as conn:
            _listener = Listener(conn)
            eventlet.spawn_n(listen, _listener)
    return _listener
Пример #2
0
 def start(self):
     try:
         self.connection = Connection(transport_utils.get_messaging_urls())
         self._updates_thread = eventlet.spawn(self.run)
     except:
         LOG.exception('Failed to start sensor_watcher.')
         self.connection.release()
Пример #3
0
def get_listener():
    global _listener
    if not _listener:
        with Connection(transport_utils.get_messaging_urls()) as conn:
            _listener = Listener(conn)
            eventlet.spawn_n(listen, _listener)
    return _listener
Пример #4
0
def register_exchanges():
    LOG.debug("Registering exchanges...")
    connection_urls = transport_utils.get_messaging_urls()

    with transport_utils.get_connection() as conn:
        # Use ConnectionRetryWrapper to deal with rmq clustering etc.
        retry_wrapper = ConnectionRetryWrapper(
            cluster_size=len(connection_urls), logger=LOG
        )

        def wrapped_register_exchanges(connection, channel):
            for exchange in EXCHANGES:
                _do_register_exchange(
                    exchange=exchange,
                    connection=connection,
                    channel=channel,
                    retry_wrapper=retry_wrapper,
                )

        retry_wrapper.run(connection=conn, wrapped_callback=wrapped_register_exchanges)

        def wrapped_predeclare_queues(connection, channel):
            for queue in QUEUES:
                _do_predeclare_queue(channel=channel, queue=queue)

        retry_wrapper.run(connection=conn, wrapped_callback=wrapped_predeclare_queues)
 def start(self):
     try:
         self.connection = Connection(transport_utils.get_messaging_urls())
         self._updates_thread = eventlet.spawn(self.run)
     except:
         LOG.exception('Failed to start sensor_watcher.')
         self.connection.release()
Пример #6
0
def main(queue, exchange, routing_key='#'):
    exchange = Exchange(exchange, type='topic')
    queue = Queue(name=queue, exchange=exchange, routing_key=routing_key,
                  auto_delete=True)

    with Connection(transport_utils.get_messaging_urls()) as connection:
        watcher = QueueConsumer(connection=connection, queue=queue)
        watcher.run()
def get_listener(name):
    global _stream_listener
    global _execution_output_listener

    if name == 'stream':
        if not _stream_listener:
            with Connection(transport_utils.get_messaging_urls()) as conn:
                _stream_listener = StreamListener(conn)
                eventlet.spawn_n(listen, _stream_listener)
        return _stream_listener
    elif name == 'execution_output':
        if not _execution_output_listener:
            with Connection(transport_utils.get_messaging_urls()) as conn:
                _execution_output_listener = ExecutionOutputListener(conn)
                eventlet.spawn_n(listen, _execution_output_listener)
        return _execution_output_listener
    else:
        raise ValueError('Invalid listener name: %s' % (name))
 def test_process_message(self):
     with Connection(transport_utils.get_messaging_urls()) as conn:
         tracker = ResultsTracker(conn, [ACTIONSTATE_WORK_Q])
         tracker._bootstrap()
         state = ActionStateConsumerTests.get_state(
             ActionStateConsumerTests.liveactions['liveaction1.yaml'])
         tracker._queue_consumer._process_message(state)
         querier = tracker.get_querier('tests.resources.test_querymodule')
         self.assertEqual(querier._query_contexts.qsize(), 1)
Пример #9
0
def get_listener(name):
    global _stream_listener
    global _execution_output_listener

    if name == 'stream':
        if not _stream_listener:
            with Connection(transport_utils.get_messaging_urls()) as conn:
                _stream_listener = StreamListener(conn)
                eventlet.spawn_n(listen, _stream_listener)
        return _stream_listener
    elif name == 'execution_output':
        if not _execution_output_listener:
            with Connection(transport_utils.get_messaging_urls()) as conn:
                _execution_output_listener = ExecutionOutputListener(conn)
                eventlet.spawn_n(listen, _execution_output_listener)
        return _execution_output_listener
    else:
        raise ValueError('Invalid listener name: %s' % (name))
Пример #10
0
 def _cleanup_old_queues(self):
     with Connection(transport_utils.get_messaging_urls()) as connection:
         for q in self.OLD_QS:
             bound_q = q(connection.default_channel)
             try:
                 bound_q.delete()
             except:
                 print('Failed to delete %s.' % q.name)
                 traceback.print_exc()
 def test_process_message(self):
     with Connection(transport_utils.get_messaging_urls()) as conn:
         tracker = ResultsTracker(conn, [ACTIONSTATE_WORK_Q])
         tracker._bootstrap()
         state = ActionStateConsumerTests.get_state(
             ActionStateConsumerTests.liveactions['liveaction1.yaml'])
         tracker._queue_consumer._process_message(state)
         querier = tracker.get_querier('tests.resources.test_querymodule')
         self.assertEqual(querier._query_contexts.qsize(), 1)
def main(queue, exchange, routing_key='#'):
    exchange = Exchange(exchange, type='topic')
    queue = Queue(name=queue,
                  exchange=exchange,
                  routing_key=routing_key,
                  auto_delete=True)

    with Connection(transport_utils.get_messaging_urls()) as connection:
        watcher = QueueConsumer(connection=connection, queue=queue)
        watcher.run()
Пример #13
0
 def __init__(self, urls=None):
     """
     :param urls: Connection URLs to use. If not provided it uses a default value from th
                  config.
     :type urls: ``list``
     """
     urls = urls or transport_utils.get_messaging_urls()
     connection = transport_utils.get_connection(
         urls=urls, connection_kwargs={"failover_strategy": "round-robin"})
     self.pool = connection.Pool(limit=10)
     self.cluster_size = len(urls)
Пример #14
0
 def __init__(self, urls=None):
     """
     :param urls: Connection URLs to use. If not provided it uses a default value from th
                  config.
     :type urls: ``list``
     """
     urls = urls or transport_utils.get_messaging_urls()
     connection = transport_utils.get_connection(urls=urls,
                                                 connection_kwargs={'failover_strategy':
                                                                    'round-robin'})
     self.pool = connection.Pool(limit=10)
     self.cluster_size = len(urls)
Пример #15
0
def register_exchanges():
    LOG.debug('Registering exchanges...')
    connection_urls = transport_utils.get_messaging_urls()
    with Connection(connection_urls) as conn:
        # Use ConnectionRetryWrapper to deal with rmq clustering etc.
        retry_wrapper = ConnectionRetryWrapper(cluster_size=len(connection_urls), logger=LOG)

        def wrapped_register_exchanges(connection, channel):
            for exchange in EXCHANGES:
                _do_register_exchange(exchange=exchange, connection=connection, channel=channel,
                                      retry_wrapper=retry_wrapper)

        retry_wrapper.run(connection=conn, wrapped_callback=wrapped_register_exchanges)
Пример #16
0
def register_exchanges():
    LOG.debug('Registering exchanges...')
    connection_urls = transport_utils.get_messaging_urls()
    with Connection(connection_urls) as conn:
        # Use ConnectionRetryWrapper to deal with rmq clustering etc.
        retry_wrapper = ConnectionRetryWrapper(cluster_size=len(connection_urls), logger=LOG)

        def wrapped_register_exchanges(connection, channel):
            for exchange in EXCHANGES:
                _do_register_exchange(exchange=exchange, connection=connection, channel=channel,
                                      retry_wrapper=retry_wrapper)

        retry_wrapper.run(connection=conn, wrapped_callback=wrapped_register_exchanges)
Пример #17
0
 def __init__(self, exchange):
     urls = transport_utils.get_messaging_urls()
     self._state_publisher = SharedPoolPublishers().get_publisher(urls=urls)
     self._state_exchange = exchange
Пример #18
0
def get_handler():
    with Connection(transport_utils.get_messaging_urls()) as conn:
        return FakeMessageHandler(conn, [FAKE_WORK_Q])
Пример #19
0
 def __init__(self, logger=LOG):
     self._publisher = AnnouncementPublisher(
         urls=transport_utils.get_messaging_urls())
     self._logger = logger
Пример #20
0
def get_tracker():
    with Connection(transport_utils.get_messaging_urls()) as conn:
        return ResultsTracker(conn, [ACTIONSTATE_WORK_Q])
Пример #21
0
def get_tracker():
    with Connection(transport_utils.get_messaging_urls()) as conn:
        return ResultsTracker(conn, [RESULTSTRACKER_ACTIONSTATE_WORK_QUEUE])
Пример #22
0
 def _get_publisher(cls):
     if not cls.publisher:
         cls.publisher = FakeModelPublisher(transport_utils.get_messaging_urls())
     return cls.publisher
Пример #23
0
 def __init__(self, logger=LOG):
     self._publisher = TriggerInstancePublisher(
         urls=transport_utils.get_messaging_urls())
     self._logger = logger
Пример #24
0
def get_notifier():
    with Connection(transport_utils.get_messaging_urls()) as conn:
        return Notifier(conn, [ACTIONUPDATE_WORK_Q], trigger_dispatcher=TriggerDispatcher(LOG))
Пример #25
0
 def _get_publisher(cls):
     if not cls.publisher:
         cls.publisher = transport.liveaction.LiveActionPublisher(
             urls=transport_utils.get_messaging_urls())
     return cls.publisher
Пример #26
0
def get_scheduler_entrypoint():
    with Connection(transport_utils.get_messaging_urls()) as conn:
        return SchedulerEntrypoint(conn, [ACTIONSCHEDULER_REQUEST_QUEUE])
Пример #27
0
 def __init__(self, exchange):
     urls = transport_utils.get_messaging_urls()
     self._state_publisher = SharedPoolPublishers().get_publisher(urls=urls)
     self._state_exchange = exchange
Пример #28
0
def get_scheduler():
    with Connection(transport_utils.get_messaging_urls()) as conn:
        return ActionExecutionScheduler(conn, [ACTIONRUNNER_REQUEST_Q])
Пример #29
0
    def _get_publisher(cls):
        if not cls.publisher:
            cls.publisher = transport.workflow.WorkflowExecutionPublisher(
                urls=transport_utils.get_messaging_urls())

        return cls.publisher
Пример #30
0
def get_engine():
    with kombu.Connection(txpt_utils.get_messaging_urls()) as conn:
        return WorkflowExecutionHandler(conn, WORKFLOW_EXECUTION_QUEUES)
Пример #31
0
def main(exchange, routing_key, payload):
    exchange = Exchange(exchange, type='topic')
    publisher = PoolPublisher(urls=transport_utils.get_messaging_urls())
    publisher.publish(payload=payload, exchange=exchange, routing_key=routing_key)
Пример #32
0
def get_worker():
    with Connection(transport_utils.get_messaging_urls()) as conn:
        return TriggerInstanceDispatcher(conn, [RULESENGINE_WORK_QUEUE])
Пример #33
0
 def _get_publisher(cls):
     if not cls.publisher:
         cls.publisher = transport.reactor.TriggerCUDPublisher(
             urls=transport_utils.get_messaging_urls())
     return cls.publisher
Пример #34
0
 def _get_publisher(cls):
     if not cls.publisher:
         cls.publisher = transport.liveaction.LiveActionPublisher(
             urls=transport_utils.get_messaging_urls())
     return cls.publisher
Пример #35
0
def get_tracker():
    with Connection(transport_utils.get_messaging_urls()) as conn:
        return ResultsTracker(conn, [RESULTSTRACKER_ACTIONSTATE_WORK_QUEUE])
Пример #36
0
 def __init__(self, logger=LOG):
     self._publisher = TriggerInstancePublisher(urls=transport_utils.get_messaging_urls())
     self._logger = logger
Пример #37
0
def get_handler():
    with Connection(transport_utils.get_messaging_urls()) as conn:
        return FakeMessageHandler(conn, [FAKE_WORK_Q])
Пример #38
0
def get_tracker():
    with Connection(transport_utils.get_messaging_urls()) as conn:
        return ResultsTracker(conn, [ACTIONSTATE_WORK_Q])
Пример #39
0
 def _get_publisher(cls):
     if not cls.publisher:
         cls.publisher = transport.execution.ActionExecutionOutputPublisher(
             urls=transport_utils.get_messaging_urls())
     return cls.publisher
Пример #40
0
def get_scheduler():
    with Connection(transport_utils.get_messaging_urls()) as conn:
        return ActionExecutionScheduler(conn, [ACTIONSCHEDULER_REQUEST_QUEUE])
Пример #41
0
def get_worker():
    with Connection(transport_utils.get_messaging_urls()) as conn:
        return ActionExecutionDispatcher(conn, [ACTIONRUNNER_WORK_Q, ACTIONRUNNER_CANCEL_Q])
Пример #42
0
 def __init__(self, logger=LOG):
     self._publisher = AnnouncementPublisher(urls=transport_utils.get_messaging_urls())
     self._logger = logger
Пример #43
0
def get_worker():
    with Connection(transport_utils.get_messaging_urls()) as conn:
        return ActionExecutionDispatcher(conn, ACTIONRUNNER_QUEUES)
Пример #44
0
def get_engine():
    with kombu.Connection(txpt_utils.get_messaging_urls()) as conn:
        return WorkflowDispatcher(conn, WORKFLOW_EXECUTION_QUEUES)
def main(exchange, routing_key, payload):
    exchange = Exchange(exchange, type='topic')
    publisher = PoolPublisher(urls=transport_utils.get_messaging_urls())
    publisher.publish(payload=payload, exchange=exchange, routing_key=routing_key)
Пример #46
0
 def _get_publisher(cls):
     if not cls.publisher:
         cls.publisher = transport.actionexecutionstate.ActionExecutionStatePublisher(
             urls=transport_utils.get_messaging_urls())
     return cls.publisher
Пример #47
0
def get_worker():
    with Connection(transport_utils.get_messaging_urls()) as conn:
        return ActionExecutionDispatcher(conn, ACTIONRUNNER_QUEUES)
Пример #48
0
def get_worker():
    with Connection(transport_utils.get_messaging_urls()) as conn:
        return ActionExecutionDispatcher(
            conn, [ACTIONRUNNER_WORK_Q, ACTIONRUNNER_CANCEL_Q])
Пример #49
0
    def _get_publisher(cls):
        if not cls.publisher:
            cls.publisher = transport.workflow.WorkflowExecutionPublisher(
                urls=transport_utils.get_messaging_urls())

        return cls.publisher
Пример #50
0
def get_notifier():
    with Connection(transport_utils.get_messaging_urls()) as conn:
        return Notifier(conn, [ACTIONUPDATE_WORK_Q],
                        trigger_dispatcher=TriggerDispatcher(LOG))
Пример #51
0
def get_worker():
    with Connection(transport_utils.get_messaging_urls()) as conn:
        return TriggerInstanceDispatcher(conn, [RULESENGINE_WORK_Q])
Пример #52
0
def get_worker():
    with Connection(transport_utils.get_messaging_urls()) as conn:
        return ExecutionsExporter(conn, [EXPORTER_WORK_Q])
Пример #53
0
 def _get_publisher(cls):
     if not cls.publisher:
         cls.publisher = transport.execution.ActionExecutionOutputPublisher(
             urls=transport_utils.get_messaging_urls())
     return cls.publisher