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


Python ParallelServer.invoke_startup_services方法代碼示例

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


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

示例1: test__startup_services

# 需要導入模塊: from zato.server.base.parallel import ParallelServer [as 別名]
# 或者: from zato.server.base.parallel.ParallelServer import invoke_startup_services [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.invoke_startup_services方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。