本文整理汇总了Python中pyon.net.endpoint.Publisher.__init__方法的典型用法代码示例。如果您正苦于以下问题:Python Publisher.__init__方法的具体用法?Python Publisher.__init__怎么用?Python Publisher.__init__使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pyon.net.endpoint.Publisher
的用法示例。
在下文中一共展示了Publisher.__init__方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from pyon.net.endpoint import Publisher [as 别名]
# 或者: from pyon.net.endpoint.Publisher import __init__ [as 别名]
def __init__(self, xp=None, **kwargs):
# generate a name
xp = xp or get_events_exchange_point()
name = (xp, None)
Publisher.__init__(self, name=name, **kwargs)
示例2: __init__
# 需要导入模块: from pyon.net.endpoint import Publisher [as 别名]
# 或者: from pyon.net.endpoint.Publisher import __init__ [as 别名]
def __init__(self, event_type=None, xp=None, process=None, **kwargs):
"""
Constructs a publisher of events for a specific type.
@param event_type The name of the event type object
@param xp Exchange (AMQP) name, can be none, will use events default.
"""
self.event_type = event_type
self.process = process
self._events_xp = CFG.get_safe("exchange.core.events", DEFAULT_EVENTS_XP)
if bootstrap.container_instance and getattr(bootstrap.container_instance, 'event_repository', None):
self.event_repo = bootstrap.container_instance.event_repository
else:
self.event_repo = None
# generate an exchange name to publish events to
container = (hasattr(self, '_process') and hasattr(self._process, 'container') and self._process.container) or BaseEndpoint._get_container_instance()
if container and container.has_capability(container.CCAP.EXCHANGE_MANAGER): # might be too early in chain
xp = xp or container.create_xp(self._events_xp)
to_name = xp
else:
xp = xp or self.get_events_exchange_point()
to_name = (xp, None)
Publisher.__init__(self, to_name=to_name, **kwargs)
示例3: __init__
# 需要导入模块: from pyon.net.endpoint import Publisher [as 别名]
# 或者: from pyon.net.endpoint.Publisher import __init__ [as 别名]
def __init__(self, xp=None, event_repo=None, **kwargs):
"""
Constructs a publisher of events.
@param xp Exchange (AMQP) name, can be none, will use events default.
@param event_repo An optional repository for published events. If None, will not store
published events. Use the Container.event_repository for this
parameter if you have one.
"""
# generate a name
xp = xp or get_events_exchange_point()
name = (xp, None)
self.event_repo = event_repo
Publisher.__init__(self, to_name=name, **kwargs)
示例4: __init__
# 需要导入模块: from pyon.net.endpoint import Publisher [as 别名]
# 或者: from pyon.net.endpoint.Publisher import __init__ [as 别名]
def __init__(self, event_type=None, xp=None, **kwargs):
"""
Constructs a publisher of events for a specific type.
@param event_type The name of the event type object
@param xp Exchange (AMQP) name, can be none, will use events default.
"""
self.event_type = event_type
if bootstrap.container_instance and getattr(bootstrap.container_instance, 'event_repository', None):
self.event_repo = bootstrap.container_instance.event_repository
else:
self.event_repo = None
# generate an exchange name to publish events to
xp = xp or get_events_exchange_point()
name = (xp, None)
Publisher.__init__(self, to_name=name, **kwargs)
示例5: __init__
# 需要导入模块: from pyon.net.endpoint import Publisher [as 别名]
# 或者: from pyon.net.endpoint.Publisher import __init__ [as 别名]
def __init__(self, process, stream, **kwargs):
"""
Creates a StreamPublisher which publishes to the specified stream
and is attached to the specified process.
@param process The IonProcess to attach to.
@param stream Name of the stream or StreamRoute object
"""
super(StreamPublisher, self).__init__()
if not isinstance(process, BaseService):
raise BadRequest("No valid process provided.")
if isinstance(stream, basestring):
self.stream_route = StreamRoute(routing_key=stream)
elif isinstance(stream, StreamRoute):
self.stream_route = stream
else:
raise BadRequest("No valid stream information provided.")
self.container = process.container
self.xp_name = get_streaming_xp(self.stream_route.exchange_point) # Fully qualified
self.xp = self.container.ex_manager.create_xp(self.stream_route.exchange_point or DEFAULT_DATA_XP)
self.xp_route = self.xp.create_route(self.stream_route.routing_key)
Publisher.__init__(self, to_name=self.xp_route, **kwargs)
示例6: __init__
# 需要导入模块: from pyon.net.endpoint import Publisher [as 别名]
# 或者: from pyon.net.endpoint.Publisher import __init__ [as 别名]
def __init__(self, process=None, **kwargs):
self._process = process
Publisher.__init__(self, **kwargs)