# Path: coolamqp/objects.py
# class ReceivedMessage(Message):
#     """
#     A message that was received from the AMQP broker.
# 
#     It additionally has an exchange name, routing key used, it's delivery tag,
#     and methods for ack() or nack().
# 
#     Note that if the consumer that generated this message was no_ack, .ack()
#     and .nack() are no-ops.
#     """
#     __slots__ = ('delivery_tag', 'exchange_name', 'routing_key', '_ack', '_nack',
#                  'acked')
# 
#     def __init__(self, body,  # type: tp.Union[str, bytes, bytearray, tp.List[memoryview]]
#                  exchange_name,  # type: memoryview
#                  routing_key,  # type: memoryview
#                  properties=None,
#                  delivery_tag=None,  # type: int
#                  ack=None,  # type: tp.Callable[[], None]
#                  nack=None  # type: tp.Callable[[], None]
#                  ):
#         """
#         :param body: message body. A stream of octets.
#         :type body: str (py2) or bytes (py3) or a list of memoryviews, if
#             particular disabled-by-default option is turned on, or a single memoryview
#         :param exchange_name: name of exchange this message was submitted to
#         :param routing_key: routing key with which this message was sent
#         :param properties: a suitable BasicContentPropertyList subinstance.
#                            be prepared that value of properties that are
#                            strings will be memoryviews
#         :param delivery_tag: delivery tag assigned by AMQP broker to confirm
#             this message
#         :param ack: a callable to call when you want to ack (via basic.ack)
#             this message. None if received by the no-ack mechanism
#         :param nack: a callable to call when you want to nack
#             (via basic.reject) this message. None if received by the no-ack
#              mechanism
#         """
#         Message.__init__(self, body, properties=properties)
# 
#         self.delivery_tag = delivery_tag
#         self.exchange_name = exchange_name
#         self.routing_key = routing_key
#         self.acked = False
#         self._ack = ack or LAMBDA_NONE
#         self._nack = nack or LAMBDA_NONE
# 
#     def ack(self):
#         """
#         Acknowledge reception of this message.
# 
#         This is a no-op if a Consumer was called with no_ack=True.
# 
#         If called after an ack() or nack() was called, this will be a no-op.
#         """
#         if self.acked:
#             return
#         self._ack()
#         self.acked = True
# 
#     def nack(self):
#         """
#         Negatively acknowledge reception of this message.
# 
#         This is a no-op if a Consumer was called with no_ack=True. If no_ack was False,
#         the message will be requeued and redelivered by the broker
# 
#         If called after an ack() or nack() was called, this will be a no-op.
#         """
#         if self.acked:
#             return
#         self._nack()
#         self.acked = True


import logging
from coolamqp.objects import ReceivedMessage

class NothingMuch(Event):
    """Nothing happened :D"""

    __slots__ = ()


class ConnectionLost(Event):
    """
    We have lost the connection.

    NOTE that we don't have a ConnectionUp, since re-establishing a connection
    is a complicated process. Broker might not have recognized the failure,
    and some queues will be blocked, some might be ok, and the state
    might be just a bit noisy.

    Please examine your Consumer's .state's to check whether link was regained
    """

    __slots__ = ()


class MessageReceived(ReceivedMessage, Event):
    """
    Something that works as an ersatz ReceivedMessage, but is an event
    """
    __slots__ = ()

    def __init__(self, msg):  # type: (ReceivedMessage) -> None
        """:type msg: ReceivedMessage"""

# Path: coolamqp/objects.py
# class ReceivedMessage(Message):
#     """
#     A message that was received from the AMQP broker.
# 
#     It additionally has an exchange name, routing key used, it's delivery tag,
#     and methods for ack() or nack().
# 
#     Note that if the consumer that generated this message was no_ack, .ack()
#     and .nack() are no-ops.
#     """
#     __slots__ = ('delivery_tag', 'exchange_name', 'routing_key', '_ack', '_nack',
#                  'acked')
# 
#     def __init__(self, body,  # type: tp.Union[str, bytes, bytearray, tp.List[memoryview]]
#                  exchange_name,  # type: memoryview
#                  routing_key,  # type: memoryview
#                  properties=None,
#                  delivery_tag=None,  # type: int
#                  ack=None,  # type: tp.Callable[[], None]
#                  nack=None  # type: tp.Callable[[], None]
#                  ):
#         """
#         :param body: message body. A stream of octets.
#         :type body: str (py2) or bytes (py3) or a list of memoryviews, if
#             particular disabled-by-default option is turned on, or a single memoryview
#         :param exchange_name: name of exchange this message was submitted to
#         :param routing_key: routing key with which this message was sent
#         :param properties: a suitable BasicContentPropertyList subinstance.
#                            be prepared that value of properties that are
#                            strings will be memoryviews
#         :param delivery_tag: delivery tag assigned by AMQP broker to confirm
#             this message
#         :param ack: a callable to call when you want to ack (via basic.ack)
#             this message. None if received by the no-ack mechanism
#         :param nack: a callable to call when you want to nack
#             (via basic.reject) this message. None if received by the no-ack
#              mechanism
#         """
#         Message.__init__(self, body, properties=properties)
# 
#         self.delivery_tag = delivery_tag
#         self.exchange_name = exchange_name
#         self.routing_key = routing_key
#         self.acked = False
#         self._ack = ack or LAMBDA_NONE
#         self._nack = nack or LAMBDA_NONE
# 
#     def ack(self):
#         """
#         Acknowledge reception of this message.
# 
#         This is a no-op if a Consumer was called with no_ack=True.
# 
#         If called after an ack() or nack() was called, this will be a no-op.
#         """
#         if self.acked:
#             return
#         self._ack()
#         self.acked = True
# 
#     def nack(self):
#         """
#         Negatively acknowledge reception of this message.
# 
#         This is a no-op if a Consumer was called with no_ack=True. If no_ack was False,
#         the message will be requeued and redelivered by the broker
# 
#         If called after an ack() or nack() was called, this will be a no-op.
#         """
#         if self.acked:
#             return
#         self._nack()
#         self.acked = True


# Path: coolamqp/clustering/events.py
import logging
from coolamqp.objects import ReceivedMessage


class NothingMuch(Event):
    """Nothing happened :D"""

    __slots__ = ()


class ConnectionLost(Event):
    """
    We have lost the connection.

    NOTE that we don't have a ConnectionUp, since re-establishing a connection
    is a complicated process. Broker might not have recognized the failure,
    and some queues will be blocked, some might be ok, and the state
    might be just a bit noisy.

    Please examine your Consumer's .state's to check whether link was regained
    """

    __slots__ = ()


class MessageReceived(ReceivedMessage, Event):
    """
    Something that works as an ersatz ReceivedMessage, but is an event
    """
    __slots__ = ()

    def __init__(self, msg):  # type: (ReceivedMessage) -> None
        """:type msg: ReceivedMessage"""

        ReceivedMessage.__init__(self, msg.body, msg.exchange_name,