當前位置: 首頁>>代碼示例>>Python>>正文


Python oslo_messaging.get_notification_listener方法代碼示例

本文整理匯總了Python中oslo_messaging.get_notification_listener方法的典型用法代碼示例。如果您正苦於以下問題:Python oslo_messaging.get_notification_listener方法的具體用法?Python oslo_messaging.get_notification_listener怎麽用?Python oslo_messaging.get_notification_listener使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在oslo_messaging的用法示例。


在下文中一共展示了oslo_messaging.get_notification_listener方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: main

# 需要導入模塊: import oslo_messaging [as 別名]
# 或者: from oslo_messaging import get_notification_listener [as 別名]
def main():
    if len(sys.argv) < 2:
        print("Supply an exchange")
        sys.exit(0)

    exchange = sys.argv[1]
    pool = sys.argv[2] if len(sys.argv) > 2 else None

    transport = oslo_messaging.get_notification_transport(
        cfg.CONF,
        url='rabbit://%s:%s@%s' % (username, password, host))
    targets = [oslo_messaging.Target(topic=topic, exchange=exchange)]
    endpoints = [EP()]
    oslo_listener = oslo_messaging.get_notification_listener(
        transport, targets, endpoints, pool=pool, executor='threading')
    try:
        print("Started")
        oslo_listener.start()
        while True:
            time.sleep(1)
    except KeyboardInterrupt:
        print("Stopping")
        oslo_listener.stop()
        oslo_listener.wait() 
開發者ID:openstack,項目名稱:searchlight,代碼行數:26,代碼來源:listener.py

示例2: start

# 需要導入模塊: import oslo_messaging [as 別名]
# 或者: from oslo_messaging import get_notification_listener [as 別名]
def start(self):
        super(ListenerService, self).start()
        transport = oslo_messaging.get_notification_transport(CONF)
        targets = [
            oslo_messaging.Target(topic=pl_topic, exchange=pl_exchange)
            for pl_topic, pl_exchange in self.topics_exchanges_set
        ]
        endpoints = [
            NotificationEndpoint(self.plugins, PipelineManager(self.plugins))
        ]
        listener = oslo_messaging.get_notification_listener(
            transport,
            targets,
            endpoints,
            executor='threading',
            pool=CONF.listener.notifications_pool)

        listener.start()
        self.listeners.append(listener) 
開發者ID:openstack,項目名稱:searchlight,代碼行數:21,代碼來源:listener.py

示例3: get_notification_listener

# 需要導入模塊: import oslo_messaging [as 別名]
# 或者: from oslo_messaging import get_notification_listener [as 別名]
def get_notification_listener(targets, endpoints, serializer=None, pool=None):
    if NOTIFICATION_TRANSPORT is None:
        raise AssertionError("'NOTIFICATION_TRANSPORT' must not be None")
    if serializer is None:
        serializer = JsonPayloadSerializer()
    return messaging.get_notification_listener(
        NOTIFICATION_TRANSPORT,
        targets,
        endpoints,
        executor='eventlet',
        pool=pool,
        serializer=serializer
    ) 
開發者ID:openstack,項目名稱:designate,代碼行數:15,代碼來源:rpc.py

示例4: get_notification_listener

# 需要導入模塊: import oslo_messaging [as 別名]
# 或者: from oslo_messaging import get_notification_listener [as 別名]
def get_notification_listener(transport, targets, endpoints,
                              allow_requeue=False):
    """Return a configured oslo_messaging notification listener."""
    return oslo_msg.get_notification_listener(
        transport, targets, endpoints, allow_requeue=allow_requeue) 
開發者ID:openstack,項目名稱:vitrage,代碼行數:7,代碼來源:messaging.py

示例5: build_notification_handler

# 需要導入模塊: import oslo_messaging [as 別名]
# 或者: from oslo_messaging import get_notification_listener [as 別名]
def build_notification_handler(self, topic_names, endpoints=()):
        serializer = rpc.RequestContextSerializer(rpc.JsonPayloadSerializer())
        targets = []
        for topic in topic_names:
            kwargs = {}
            if '.' in topic:
                exchange, topic = topic.split('.')
                kwargs['exchange'] = exchange
            kwargs['topic'] = topic
            targets.append(om.Target(**kwargs))
        return om.get_notification_listener(
            self.notification_transport, targets, endpoints,
            executor='eventlet', serializer=serializer,
            allow_requeue=False, pool=CONF.host) 
開發者ID:openstack,項目名稱:watcher,代碼行數:16,代碼來源:service.py

示例6: ListenerProc

# 需要導入模塊: import oslo_messaging [as 別名]
# 或者: from oslo_messaging import get_notification_listener [as 別名]
def ListenerProc(exchange, project_id, cluster_id, recover_action):
    """Thread procedure for running an event listener.

    :param exchange: The control exchange for a target service.
    :param project_id: The ID of the project to filter.
    :param cluster_id: The ID of the cluster to filter.
    :param recover_action: The health policy action name.
    """
    transport = messaging.get_notification_transport(cfg.CONF)

    if exchange == cfg.CONF.health_manager.nova_control_exchange:
        endpoint = nova_endpoint.NovaNotificationEndpoint(
            project_id, cluster_id, recover_action
        )

    else:
        endpoint = heat_endpoint.HeatNotificationEndpoint(
            project_id, cluster_id, recover_action
        )

    listener = messaging.get_notification_listener(
        transport, [endpoint.target], [endpoint], executor='threading',
        pool='senlin-listeners'
    )

    listener.start() 
開發者ID:openstack,項目名稱:senlin,代碼行數:28,代碼來源:health_manager.py


注:本文中的oslo_messaging.get_notification_listener方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。