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


Python PubsubManagementServiceProcessClient.create_stream方法代码示例

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


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

示例1: __init__

# 需要导入模块: from interface.services.dm.ipubsub_management_service import PubsubManagementServiceProcessClient [as 别名]
# 或者: from interface.services.dm.ipubsub_management_service.PubsubManagementServiceProcessClient import create_stream [as 别名]
    def __init__(self, process=None, stream_id='', stream_route=None, exchange_point='', routing_key=''):
        '''
        Creates a StreamPublisher which publishes to the specified stream by default and is attached to the
        specified process.
        @param process        The process which the subscriber is to be attached.
        @param stream_id      Stream identifier for the publishing stream.
        @param stream_route   A StreamRoute corresponding to the stream_id
        @param exchange_point The name of the exchange point, to be used in lieu of stream_route or stream_id
        @param routing_key    The routing key to be used in lieu of stream_route or stream_id
        '''
        super(StreamPublisher, self).__init__()
        validate_is_instance(process, BaseService, 'No valid process provided.')
        #--------------------------------------------------------------------------------
        # The important part of publishing is the stream_route and there are three ways
        # to the stream route
        #   - The Route is obtained from Pubsub Management with a stream id.
        #   - The Route is obtained by combining exchange_point and the routing_key
        #     but all other information is lost (credentials, etc.)
        #   - The Route is obtained by being provided directly to __init__
        #--------------------------------------------------------------------------------
        self.stream_id = stream_id
        if stream_id:
            # Regardless of what's passed in for stream_route look it up, prevents mismatching
            pubsub_cli = PubsubManagementServiceProcessClient(process=process, node=process.container.node)
            self.stream_route = pubsub_cli.read_stream_route(stream_id)

        elif not stream_route:
            self.stream_route = None
            if exchange_point and routing_key:
                self.stream_route = StreamRoute(exchange_point=exchange_point, routing_key=routing_key)
            else:
                pubsub_cli = PubsubManagementServiceProcessClient(process=process, node=process.container.node)
                stream_id, stream_route = pubsub_cli.create_stream(process.id, exchange_point=exchange_point or 'void')
                self.stream_id = stream_id
                self.stream_route = stream_route
        else:
            self.stream_route = stream_route
        validate_is_instance(self.stream_route, StreamRoute, 'No valid stream route provided to publisher.')

        self.container = process.container
        self.xp = self.container.ex_manager.create_xp(self.stream_route.exchange_point)
        self.xp_route = self.xp.create_route(self.stream_route.routing_key)
开发者ID:lukecampbell,项目名称:pyon,代码行数:44,代码来源:stream.py


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