Пример #1
0
 def __init__(self,
              hostname,
              sasl,
              container_id=False,
              max_frame_size=None,
              channel_max=None,
              idle_timeout=None,
              properties=None,
              remote_idle_timeout_empty_frame_send_ratio=None,
              error_policy=None,
              debug=False,
              encoding='UTF-8',
              loop=None):
     self._internal_kwargs = get_dict_with_loop_if_needed(loop)
     super(ConnectionAsync,
           self).__init__(hostname,
                          sasl,
                          container_id=container_id,
                          max_frame_size=max_frame_size,
                          channel_max=channel_max,
                          idle_timeout=idle_timeout,
                          properties=properties,
                          remote_idle_timeout_empty_frame_send_ratio=
                          remote_idle_timeout_empty_frame_send_ratio,
                          error_policy=error_policy,
                          debug=debug,
                          encoding=encoding)
     self._async_lock = asyncio.Lock(**self._internal_kwargs)
Пример #2
0
    def __init__(
            self,
            remote_address,
            auth=None,
            client_name=None,
            loop=None,
            debug=False,
            error_policy=None,
            keep_alive_interval=None,
            **kwargs):

        self._internal_kwargs = get_dict_with_loop_if_needed(loop)

        super(AMQPClientAsync, self).__init__(
            remote_address,
            auth=auth,
            client_name=client_name,
            debug=debug,
            error_policy=error_policy,
            keep_alive_interval=keep_alive_interval,
            **kwargs)

        # AMQP object settings
        self.connection_type = ConnectionAsync
        self.session_type = SessionAsync
Пример #3
0
 def __init__(self,
              session,
              source,
              target,
              on_message_received,
              name=None,
              receive_settle_mode=constants.ReceiverSettleMode.PeekLock,
              send_settle_mode=constants.SenderSettleMode.Unsettled,
              max_message_size=constants.MAX_MESSAGE_LENGTH_BYTES,
              prefetch=300,
              properties=None,
              error_policy=None,
              debug=False,
              encoding='UTF-8',
              desired_capabilities=None,
              loop=None):
     self._internal_kwargs = get_dict_with_loop_if_needed(loop)
     super(MessageReceiverAsync,
           self).__init__(session,
                          source,
                          target,
                          on_message_received,
                          name=name,
                          receive_settle_mode=receive_settle_mode,
                          send_settle_mode=send_settle_mode,
                          max_message_size=max_message_size,
                          prefetch=prefetch,
                          properties=properties,
                          error_policy=error_policy,
                          debug=debug,
                          encoding=encoding,
                          desired_capabilities=desired_capabilities)
Пример #4
0
    def __init__(
            self,
            source,
            auth=None,
            client_name=None,
            loop=None,
            debug=False,
            timeout=0,
            auto_complete=True,
            error_policy=None,
            keep_alive_interval=None,
            **kwargs):
        self._internal_kwargs = get_dict_with_loop_if_needed(loop)
        client.ReceiveClient.__init__(
            self,
            source,
            auth=auth,
            client_name=client_name,
            debug=debug,
            timeout=timeout,
            auto_complete=auto_complete,
            error_policy=error_policy,
            keep_alive_interval=keep_alive_interval,
            **kwargs)

        # AMQP object settings
        self.receiver_type = MessageReceiverAsync
Пример #5
0
    def __init__(
            self,
            target,
            auth=None,
            client_name=None,
            loop=None,
            debug=False,
            msg_timeout=0,
            error_policy=None,
            keep_alive_interval=None,
            **kwargs):
        self._internal_kwargs = get_dict_with_loop_if_needed(loop)
        client.SendClient.__init__(
            self,
            target,
            auth=auth,
            client_name=client_name,
            debug=debug,
            msg_timeout=msg_timeout,
            error_policy=error_policy,
            keep_alive_interval=keep_alive_interval,
            **kwargs)

        # AMQP object settings
        self.sender_type = MessageSenderAsync
        self._pending_messages_lock = asyncio.Lock(**self._internal_kwargs)
 def __init__(self, connection,
              incoming_window=None,
              outgoing_window=None,
              handle_max=None,
              on_attach=None,
              loop=None):
     self._internal_kwargs = get_dict_with_loop_if_needed(loop)
     super(SessionAsync, self).__init__(
         connection,
         incoming_window=incoming_window,
         outgoing_window=outgoing_window,
         handle_max=handle_max,
         on_attach=on_attach)
 def __init__(self,
              session,
              target=None,
              debug=False,
              status_code_field=b'statusCode',
              description_fields=b'statusDescription',
              encoding='UTF-8',
              loop=None):
     self._internal_kwargs = get_dict_with_loop_if_needed(loop)
     super(MgmtOperationAsync,
           self).__init__(session,
                          target=target,
                          debug=debug,
                          status_code_field=status_code_field,
                          description_fields=description_fields,
                          encoding=encoding)
Пример #8
0
    async def create_authenticator_async(self,
                                         connection,
                                         debug=False,
                                         loop=None,
                                         **kwargs):
        """Create the async AMQP session and the CBS channel with which
        to negotiate the token.

        :param connection: The underlying AMQP connection on which
         to create the session.
        :type connection: ~uamqp.async_ops.connection_async.ConnectionAsync
        :param debug: Whether to emit network trace logging events for the
         CBS session. Default is `False`. Logging events are set at INFO level.
        :type debug: bool
        :rtype: uamqp.c_uamqp.CBSTokenAuth
        """
        self._internal_kwargs = get_dict_with_loop_if_needed(loop)
        self._connection = connection
        kwargs.update(self._internal_kwargs)
        self._session = SessionAsync(connection, **kwargs)

        try:
            self._cbs_auth = c_uamqp.CBSTokenAuth(
                self.audience,
                self.token_type,
                self.token,
                int(self.expires_at),
                self._session._session,  # pylint: disable=protected-access
                self.timeout,
                self._connection.container_id,
                self._refresh_window)
            self._cbs_auth.set_trace(debug)
        except ValueError:
            await self._session.destroy_async()
            raise errors.AMQPConnectionError(
                "Unable to open authentication session on connection {}.\n"
                "Please confirm target hostname exists: {}".format(
                    connection.container_id, connection.hostname)) from None
        return self._cbs_auth