当前位置: 首页>>代码示例>>Python>>正文


Python Channel.get_all方法代码示例

本文整理汇总了Python中junebug.channel.Channel.get_all方法的典型用法代码示例。如果您正苦于以下问题:Python Channel.get_all方法的具体用法?Python Channel.get_all怎么用?Python Channel.get_all使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在junebug.channel.Channel的用法示例。


在下文中一共展示了Channel.get_all方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_get_all_channels

# 需要导入模块: from junebug.channel import Channel [as 别名]
# 或者: from junebug.channel.Channel import get_all [as 别名]
    def test_get_all_channels(self):
        channels = yield Channel.get_all(self.redis)
        self.assertEqual(channels, set())

        channel1 = yield self.create_channel(
            self.service, self.redis, TelnetServerTransport)
        channels = yield Channel.get_all(self.redis)
        self.assertEqual(channels, set([channel1.id]))

        channel2 = yield self.create_channel(
            self.service, self.redis, TelnetServerTransport)
        channels = yield Channel.get_all(self.redis)
        self.assertEqual(channels, set([channel1.id, channel2.id]))
开发者ID:westerncapelabs,项目名称:junebug,代码行数:15,代码来源:test_channel.py

示例2: health_status

# 需要导入模块: from junebug.channel import Channel [as 别名]
# 或者: from junebug.channel.Channel import get_all [as 别名]
    def health_status(self, request):
        if self.config.rabbitmq_management_interface:

            def get_queues(channel_ids):

                gets = []

                for channel_id in channel_ids:
                    for sub in ['inbound', 'outbound', 'event']:
                        queue_name = "%s.%s" % (channel_id, sub)

                        get = self.rabbitmq_management_client.get_queue(
                            self.amqp_config['vhost'], queue_name)
                        gets.append(get)

                return gets

            def return_queue_results(results):
                queues = []
                stuck = False

                for result in results:
                    queue = result[1]

                    if ('messages' in queue):
                        details = {
                            'name': queue['name'],
                            'stuck': False,
                            'messages': queue.get('messages'),
                            'rate': queue['messages_details']['rate']
                        }
                        if (details['messages'] > 0 and details['rate'] == 0):
                            stuck = True
                            details['stuck'] = True

                        queues.append(details)

                status = 'queues ok'
                code = http.OK
                if stuck:
                    status = "queues stuck"
                    code = http.INTERNAL_SERVER_ERROR

                return response(request, status, queues, code=code)

            d = Channel.get_all(self.redis)
            d.addCallback(get_queues)
            d.addCallback(defer.DeferredList)
            d.addCallback(return_queue_results)
            return d
        else:
            return response(request, 'health ok', {})
开发者ID:praekelt,项目名称:junebug,代码行数:54,代码来源:api.py

示例3: get_channel_list

# 需要导入模块: from junebug.channel import Channel [as 别名]
# 或者: from junebug.channel.Channel import get_all [as 别名]
 def get_channel_list(self, request):
     '''List all channels'''
     ids = yield Channel.get_all(self.redis)
     returnValue(response(request, 'channels listed', sorted(ids)))
开发者ID:westerncapelabs,项目名称:junebug,代码行数:6,代码来源:api.py


注:本文中的junebug.channel.Channel.get_all方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。