Skip to content

PatchedMessage

faststream.nats.testing.PatchedMessage #

PatchedMessage(
    _client,
    subject="",
    reply="",
    data=b"",
    headers=None,
    _metadata=None,
    _ackd=False,
    _sid=None,
)

Bases: Msg

subject class-attribute instance-attribute #

subject = ''

reply class-attribute instance-attribute #

reply = ''

data class-attribute instance-attribute #

data = b''

headers class-attribute instance-attribute #

headers = None

header property #

header

header returns the headers from a message.

sid property #

sid

sid returns the subscription ID from a message.

metadata property #

metadata

metadata returns the Metadata of a JetStream message.

Ack #

Ack class-attribute instance-attribute #

Ack = b'+ACK'

Nak class-attribute instance-attribute #

Nak = b'-NAK'

Progress class-attribute instance-attribute #

Progress = b'+WPI'

Term class-attribute instance-attribute #

Term = b'+TERM'

Prefix0 class-attribute instance-attribute #

Prefix0 = '$JS'

Prefix1 class-attribute instance-attribute #

Prefix1 = 'ACK'

Domain class-attribute instance-attribute #

Domain = 2

AccHash class-attribute instance-attribute #

AccHash = 3

Stream class-attribute instance-attribute #

Stream = 4

Consumer class-attribute instance-attribute #

Consumer = 5

NumDelivered class-attribute instance-attribute #

NumDelivered = 6

StreamSeq class-attribute instance-attribute #

StreamSeq = 7

ConsumerSeq class-attribute instance-attribute #

ConsumerSeq = 8

Timestamp class-attribute instance-attribute #

Timestamp = 9

NumPending class-attribute instance-attribute #

NumPending = 10

Metadata dataclass #

Metadata(
    sequence,
    num_pending,
    num_delivered,
    timestamp,
    stream,
    consumer,
    domain=None,
)

Metadata is the metadata from a JetStream message.

  • num_pending is the number of available messages in the Stream that have not been consumed yet.
  • num_delivered is the number of times that this message has been delivered. For example, num_delivered higher than one means that there have been redeliveries.
  • timestamp is the time at which the message was delivered.
  • stream is the name of the stream.
  • consumer is the name of the consumer.

sequence instance-attribute #

sequence

num_pending instance-attribute #

num_pending

num_delivered instance-attribute #

num_delivered

timestamp instance-attribute #

timestamp

stream instance-attribute #

stream

consumer instance-attribute #

consumer

domain class-attribute instance-attribute #

domain = None

SequencePair dataclass #

SequencePair(consumer, stream)

SequencePair represents a pair of consumer and stream sequence.

consumer instance-attribute #
consumer
stream instance-attribute #
stream

respond async #

respond(data)

respond replies to the inbox of the message if there is one.

Source code in nats/aio/msg.py
async def respond(self, data: bytes) -> None:
    """
    respond replies to the inbox of the message if there is one.
    """
    if not self.reply:
        raise Error('no reply subject available')
    if not self._client:
        raise Error('client not set')

    await self._client.publish(self.reply, data, headers=self.headers)

ack async #

ack()
Source code in faststream/nats/testing.py
async def ack(self) -> None:
    pass

ack_sync async #

ack_sync(timeout=1)
Source code in faststream/nats/testing.py
async def ack_sync(
    self,
    timeout: float = 1,
) -> "PatchedMessage":  # pragma: no cover
    return self

nak async #

nak(delay=None)
Source code in faststream/nats/testing.py
async def nak(self, delay: Union[int, float, None] = None) -> None:
    pass

term async #

term()
Source code in faststream/nats/testing.py
async def term(self) -> None:
    pass

in_progress async #

in_progress()
Source code in faststream/nats/testing.py
async def in_progress(self) -> None:
    pass