Exemple #1
0
async def confirm_subscription(convo, output_queue=None, event_number=1, commit_pos=1):

    response = proto.SubscriptionConfirmation()
    response.last_event_number = event_number
    response.last_commit_position = commit_pos

    await convo.respond_to(
        InboundMessage(
            uuid4(), TcpCommand.SubscriptionConfirmation, response.SerializeToString()
        ),
        output_queue,
    )

    return await convo.result
Exemple #2
0
    async def reply_from_init(self, message: InboundMessage, output: Queue):
        self.expect_only(TcpCommand.SubscriptionConfirmation, message)

        result = proto.SubscriptionConfirmation()
        result.ParseFromString(message.payload)

        self.subscription = VolatileSubscription(
            self.conversation_id,
            self.stream,
            output,
            result.last_event_number,
            result.last_commit_position,
        )

        self.is_live = True
        self.result.set_result(self.subscription)
Exemple #3
0
 async def reply_from_catch_up(self, message, output):
     if message.command == TcpCommand.SubscriptionDropped:
         await self.drop_subscription(message)
     elif message.command == TcpCommand.SubscriptionConfirmation:
         confirmation = proto.SubscriptionConfirmation()
         confirmation.ParseFromString(message.payload)
         self.subscribe_from = confirmation.last_event_number
         self._logger.info(
             "Subscribed successfully, catching up with missed events from %s",
             self.next_event_number,
         )
         await output.put(self._fetch_page_message(self.next_event_number))
     elif message.command == TcpCommand.StreamEventAppeared:
         result = proto.StreamEventAppeared()
         result.ParseFromString(message.payload)
         self.buffer.append(_make_event(result.event))
     else:
         await ReadStreamEventsBehaviour.reply(self, message, output)