Exemple #1
0
    async def start(self, output: Queue) -> None:
        msg = proto.SubscribeToStream()
        msg.event_stream_id = self.stream
        msg.resolve_link_tos = self.resolve_link_tos

        await output.put(
            OutboundMessage(
                self.conversation_id,
                TcpCommand.SubscribeToStream,
                msg.SerializeToString(),
                self.credential,
            ))
Exemple #2
0
async def test_subscribe_to_stream():

    output = TeeQueue()
    convo = SubscribeToStream("my-stream")
    await convo.start(output)
    [request] = output.items

    payload = proto.SubscribeToStream()
    payload.ParseFromString(request.payload)

    assert request.command == TcpCommand.SubscribeToStream
    assert payload.event_stream_id == "my-stream"
    assert payload.resolve_link_tos is True
async def test_subscribes_at_end_of_stream():
    """
    When we have read all the events in the stream, we should send a
    request to subscribe for new events.
    """

    convo = CatchupSubscription("my-stream")
    output = TeeQueue()
    await convo.start(output)
    await output.get()

    await reply_to(
        convo,
        ReadStreamEventsResponseBuilder().at_end_of_stream().build(), output)

    reply = await output.get()
    payload = proto.SubscribeToStream()
    payload.ParseFromString(reply.payload)

    assert reply.command == msg.TcpCommand.SubscribeToStream
    assert payload.event_stream_id == "my-stream"
    assert payload.resolve_link_tos is True