Exemplo n.º 1
0
    def __init__(self,
                 xp_name=None,
                 event_type=None,
                 origin=None,
                 queue_name=None,
                 callback=None,
                 sub_type=None,
                 origin_type=None,
                 process=None,
                 routing_call=None,
                 *args,
                 **kwargs):

        BaseEventSubscriberMixin.__init__(self,
                                          xp_name=xp_name,
                                          event_type=event_type,
                                          origin=origin,
                                          queue_name=queue_name,
                                          sub_type=sub_type,
                                          origin_type=origin_type)

        log.debug("EventPublisher events pattern %s", self.binding)

        ProcessSubscriber.__init__(self,
                                   from_name=self._ev_recv_name,
                                   binding=self.binding,
                                   callback=callback,
                                   process=process,
                                   routing_call=routing_call,
                                   **kwargs)
Exemplo n.º 2
0
    def __init__(self, xp_name=None, event_type=None, origin=None, queue_name=None, callback=None,
                 sub_type=None, origin_type=None, process=None, routing_call=None, *args, **kwargs):

        BaseEventSubscriberMixin.__init__(self, xp_name=xp_name, event_type=event_type, origin=origin,
                                          queue_name=queue_name, sub_type=sub_type, origin_type=origin_type)

        log.debug("EventPublisher events pattern %s", self.binding)

        ProcessSubscriber.__init__(self, from_name=self._ev_recv_name, binding=self.binding, callback=callback, process=process, routing_call=routing_call, **kwargs)
Exemplo n.º 3
0
    def _build_header(self, raw_msg):
        """
        Builds the header for this Process-level RPC conversation.
        https://confluence.oceanobservatories.org/display/syseng/CIAD+COI+OV+Common+Message+Format
        """

        header = EndpointUnit._build_header(self, raw_msg)

        # add our process identity to the headers
        header.update({
            'sender-name': self._process.name or 'unnamed-process',  # @TODO
            'sender': self._process.id
        })

        if hasattr(self._process, 'process_type'):
            header.update({
                'sender-type':
                self._process.process_type or 'unknown-process-type'
            })
            if self._process.process_type == 'service':
                header.update({
                    'sender-service':
                    "%s,%s" %
                    (self.channel._send_name.exchange, self._process.name)
                })

        context = self._process.get_context()
        log.debug('ProcessEndpointUnitMixin._build_header has context of: %s',
                  context)

        # use context to set security attributes forward
        if isinstance(context, dict):
            # fwd on actor specific information, according to common message format spec
            actor_id = context.get('ion-actor-id', None)
            actor_roles = context.get('ion-actor-roles', None)
            actor_tokens = context.get('ion-actor-tokens', None)
            expiry = context.get('expiry', None)
            container_id = context.get('origin-container-id', None)

            #If an actor-id is specified then there may be other associated data that needs to be passed on
            if actor_id:
                header['ion-actor-id'] = actor_id
                if actor_roles: header['ion-actor-roles'] = actor_roles
                if actor_tokens: header['ion-actor-tokens'] = actor_tokens

            if expiry: header['expiry'] = expiry
            if container_id: header['origin-container-id'] = container_id
        else:
            # no context? we're the originator of the message then
            container_id = BaseEndpoint._get_container_instance().id
            header['origin-container-id'] = container_id

        return header
Exemplo n.º 4
0
    def create_publisher(self, stream_id):
        """
        Call pubsub service to register this exchange name (endpoint) to publish on a particular stream
        Return a stream publisher object to publish (send) messages on a particular stream
        """
        log.debug('Creating publisher...')

        # Call the pubsub service to register the exchange name as a publisher for this stream
        stream_route = self.pubsub_client.register_producer(self.exchange_name, stream_id)

        # Create the Stream publisher, ready to publish messages to the stream
        return StreamPublisher(name=(self.XP, stream_route.routing_key), process=self.process, node=self.node)
Exemplo n.º 5
0
    def create_publisher(self, stream_id):
        """
        Call pubsub service to register this exchange name (endpoint) to publish on a particular stream
        Return a stream publisher object to publish (send) messages on a particular stream
        """
        log.debug('Creating publisher...')

        # Call the pubsub service to register the exchange name as a publisher for this stream
        stream_route = self.pubsub_client.register_producer(
            self.exchange_name, stream_id)

        # Create the Stream publisher, ready to publish messages to the stream
        return StreamPublisher(name=(self.XP, stream_route.routing_key),
                               process=self.process,
                               node=self.node)
Exemplo n.º 6
0
    def create_publisher(self, stream_id):
        """
        Call pubsub service to register this exchange name (endpoint) to publish on a particular stream
        Return a stream publisher object to publish (send) messages on a particular stream
        """
        log.debug('Creating publisher...')

        # Call the pubsub service to register the exchange name as a publisher for this stream
        stream_route = self.pubsub_client.register_producer(self.exchange_name, stream_id)

        # create an XP and XPRoute
        xp = self.container.ex_manager.create_xp(self.xp_base)
        xpr = xp.create_route(stream_route.routing_key)

        # Create the Stream publisher, ready to publish messages to the stream
        return StreamPublisher(to_name=xpr, process=self.process, node=self.container.node)
Exemplo n.º 7
0
    def _build_header(self, raw_msg):
        """
        Builds the header for this Process-level RPC conversation.
        https://confluence.oceanobservatories.org/display/syseng/CIAD+COI+OV+Common+Message+Format
        """

        header = EndpointUnit._build_header(self, raw_msg)

        # add our process identity to the headers
        header.update({'sender-name'  : self._process.name or 'unnamed-process',     # @TODO
                       'sender'       : self._process.id })

        if hasattr(self._process,'process_type' ):
            header.update({'sender-type'  : self._process.process_type or 'unknown-process-type' })
            if self._process.process_type == 'service':
                header.update({ 'sender-service' : "%s,%s" % ( self.channel._send_name.exchange,self._process.name) })

        context = self._process.get_context()
        log.debug('ProcessEndpointUnitMixin._build_header has context of: %s', context)

        # use context to set security attributes forward
        if isinstance(context, dict):
            # fwd on actor specific information, according to common message format spec
            actor_id            = context.get('ion-actor-id', None)
            actor_roles         = context.get('ion-actor-roles', None)
            actor_tokens        = context.get('ion-actor-tokens', None)
            expiry              = context.get('expiry', None)
            container_id        = context.get('origin-container-id', None)

            #If an actor-id is specified then there may be other associated data that needs to be passed on
            if actor_id:
                header['ion-actor-id']  = actor_id
                if actor_roles:     header['ion-actor-roles']   = actor_roles
                if actor_tokens:    header['ion-actor-tokens']  = actor_tokens

            if expiry:          header['expiry']                = expiry
            if container_id:    header['origin-container-id']   = container_id
        else:
            # no context? we're the originator of the message then
            container_id                    = BaseEndpoint._get_container_instance().id
            header['origin-container-id']   = container_id

        return header
Exemplo n.º 8
0
    def create_publisher(self, stream_id):
        """
        Call pubsub service to register this exchange name (endpoint) to publish on a particular stream
        Return a stream publisher object to publish (send) messages on a particular stream
        """
        log.debug('Creating publisher...')

        # Call the pubsub service to register the exchange name as a publisher for this stream
        stream_route = self.pubsub_client.register_producer(
            self.exchange_name, stream_id)

        # create an XP and XPRoute
        xp = self.container.ex_manager.create_xp(self.xp_base)
        xpr = xp.create_route(stream_route.routing_key)

        # Create the Stream publisher, ready to publish messages to the stream
        return StreamPublisher(to_name=xpr,
                               process=self.process,
                               node=self.container.node)
Exemplo n.º 9
0
 def _bind(self, binding):
     log.debug("StreamSubscriber passing on _bind: %s", binding)
Exemplo n.º 10
0
 def _bind(self, binding):
     log.debug("StreamSubscriber passing on _bind: %s", binding)