Skip to content

PatchedMessage

faststream.nats.test.PatchedMessage #

Bases: Msg

data class-attribute instance-attribute #

data: bytes = b''

header property #

header: Optional[Dict[str, str]]

header returns the headers from a message.

headers class-attribute instance-attribute #

headers: Optional[Dict[str, str]] = None

metadata property #

metadata: Metadata

metadata returns the Metadata of a JetStream message.

reply class-attribute instance-attribute #

reply: str = ''

sid property #

sid: int

sid returns the subscription ID from a message.

subject class-attribute instance-attribute #

subject: str = ''

Ack #

AccHash class-attribute instance-attribute #

AccHash = 3

Ack class-attribute instance-attribute #

Ack = b'+ACK'

Consumer class-attribute instance-attribute #

Consumer = 5

ConsumerSeq class-attribute instance-attribute #

ConsumerSeq = 8

Domain class-attribute instance-attribute #

Domain = 2

Nak class-attribute instance-attribute #

Nak = b'-NAK'

NumDelivered class-attribute instance-attribute #

NumDelivered = 6

NumPending class-attribute instance-attribute #

NumPending = 10

Prefix0 class-attribute instance-attribute #

Prefix0 = '$JS'

Prefix1 class-attribute instance-attribute #

Prefix1 = 'ACK'

Progress class-attribute instance-attribute #

Progress = b'+WPI'

Stream class-attribute instance-attribute #

Stream = 4

StreamSeq class-attribute instance-attribute #

StreamSeq = 7

Term class-attribute instance-attribute #

Term = b'+TERM'

Timestamp class-attribute instance-attribute #

Timestamp = 9

Metadata dataclass #

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.

consumer instance-attribute #

consumer: str

domain class-attribute instance-attribute #

domain: Optional[str] = None

num_delivered instance-attribute #

num_delivered: int

num_pending instance-attribute #

num_pending: int

sequence instance-attribute #

sequence: SequencePair

stream instance-attribute #

stream: str

timestamp instance-attribute #

timestamp: datetime.datetime

SequencePair dataclass #

SequencePair represents a pair of consumer and stream sequence.

consumer instance-attribute #
consumer: int
stream instance-attribute #
stream: int

ack async #

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

ack_sync async #

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

in_progress async #

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

nak async #

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

respond async #

respond(data: bytes) -> None

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)

term async #

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

Last update: 2023-11-13