Ejemplo n.º 1
0
    async def ack(self,
                  processed: List[int],
                  rejected: List[int],
                  channel: ServiceChannel,
                  need_ack: bool = False) -> None:
        """
        Acknowledge received messages that have `need_ack` flag set.

        Args:
            processed: Processed sequence numbers
            rejected: Rejected sequence numbers
            channel: Channel to send the ack on
            need_ack: Whether we want this ack to be acknowledged by the target
                      participant.
                      Will be blocking if set.
                      Required for heartbeat messages.

        Returns: None
        """
        low_watermark = self._seq_mgr.low_watermark
        msg = factory.acknowledge(low_watermark,
                                  processed,
                                  rejected,
                                  need_ack=need_ack)
        await self.send_message(msg, channel=channel, blocking=need_ack)
Ejemplo n.º 2
0
    def ack(self, processed, rejected, channel, need_ack=False):
        """
        Acknowledge received messages that have `need_ack` flag set.

        Args:
            processed (list): Processed sequence numbers
            rejected (list): Rejected sequence numbers
            channel (:class:`ServiceChannel`): Channel to send the ack on
            need_ack (bool): Whether we want this ack to be ack'd. Will be blocking if set.
                             Required for heartbeat messages.

        Returns: None
        """
        low_watermark = self._seq_mgr.low_watermark
        msg = factory.acknowledge(low_watermark,
                                  processed,
                                  rejected,
                                  need_ack=need_ack)
        self.send_message(msg, channel=channel, blocking=need_ack)
Ejemplo n.º 3
0
def test_acknowledge(packets, crypto):
    bin_name = 'acknowledge'
    msg = factory.acknowledge(low_watermark=0,
                              processed_list=[1],
                              rejected_list=[])
    msg.header(sequence_number=1,
               target_participant_id=31,
               channel_id=1152921504606846976)
    msg.header.flags(version=2, need_ack=False)
    packed = _pack(msg, crypto)

    assert msg.header.pkt_type == enum.PacketType.Message
    assert msg.header.flags.msg_type == enum.MessageType.Ack

    assert msg.protected_payload.low_watermark == 0
    assert msg.protected_payload.processed_list == [1]
    assert msg.protected_payload.rejected_list == []

    assert len(packed) == len(packets[bin_name])
    assert packed == packets[bin_name]