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)
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)
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)
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)
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)
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)
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)
def __init__(self, process=None, **kwargs): self._process = process Publisher.__init__(self, **kwargs)