def persistent_subscription_dropped(conversation_id: UUID, reason: msg.SubscriptionDropReason): payload = proto.SubscriptionDropped() payload.reason = reason return msg.OutboundMessage(conversation_id, msg.TcpCommand.SubscriptionDropped, payload.SerializeToString())
async def drop_subscription(convo, reason=SubscriptionDropReason): response = proto.SubscriptionDropped() response.reason = reason await convo.respond_to( InboundMessage(uuid4(), TcpCommand.SubscriptionDropped, response.SerializeToString()), None, )
async def drop_subscription( convo, output, reason=msg.SubscriptionDropReason.Unsubscribed ): response = proto.SubscriptionDropped() response.reason = reason await convo.respond_to( msg.InboundMessage( uuid.uuid4(), msg.TcpCommand.SubscriptionDropped, response.SerializeToString(), ), output, )
async def drop_subscription(self, response: InboundMessage) -> None: body = proto.SubscriptionDropped() body.ParseFromString(response.payload) if self.is_live and body.reason == messages.SubscriptionDropReason.Unsubscribed: await self.subscription.events.enqueue(StopAsyncIteration()) return if self.is_live: await self.error( exceptions.SubscriptionFailed(self.conversation_id, body.reason) ) return await self.error( exceptions.SubscriptionCreationFailed(self.conversation_id, body.reason) )