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


Python ParallelServer.broker_client方法代码示例

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


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

示例1: test__startup_services

# 需要导入模块: from zato.server.base.parallel import ParallelServer [as 别名]
# 或者: from zato.server.base.parallel.ParallelServer import broker_client [as 别名]
    def test__startup_services(self):

        class FakeBrokerClient(object):
            def __init__(self):
                self.messages = {}
                
            def invoke_async(self, msg):
                self.messages[msg['service']] = msg
                
        broker_client = FakeBrokerClient()
        
        startup_services = Bunch()
        for x in range(10):
            name =  rand_string()
            payload = rand_string()
            startup_services[name] = payload
        
        ps = ParallelServer()
        ps.broker_client = broker_client
        ps.fs_server_config = Bunch()
        ps.fs_server_config.startup_services = startup_services
        
        ps.invoke_startup_services()
        
        for expected_service, expected_payload in startup_services.items():
            msg = Bunch(broker_client.messages[expected_service])
            eq_(msg.action, SERVICE.PUBLISH)
            eq_(msg.channel, CHANNEL.STARTUP_SERVICE)
            eq_(msg.payload, expected_payload)
            eq_(msg.service, expected_service)
            ok_(msg.cid.startswith('K'))
            self.assertEquals(len(msg.cid), 40)
开发者ID:alex-hutton,项目名称:zato,代码行数:34,代码来源:test_parallel.py


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