Skip to content

KvParser

faststream.nats.parser.KvParser #

KvParser(*, pattern: str)

Bases: NatsBaseParser

Source code in faststream/nats/parser.py
29
30
31
32
33
34
35
def __init__(
    self,
    *,
    pattern: str,
) -> None:
    path_re, _ = compile_nats_wildcard(pattern)
    self._path_re = path_re

parse_message async #

parse_message(msg: Entry) -> StreamMessage[Entry]
Source code in faststream/nats/parser.py
150
151
152
153
154
155
156
157
158
async def parse_message(
    self,
    msg: "KeyValue.Entry",
) -> StreamMessage["KeyValue.Entry"]:
    return NatsKvMessage(
        raw_message=msg,
        body=msg.value,
        path=match_path(self._path_re, msg.key),
    )

decode_message async #

decode_message(msg: StreamMessage[Any]) -> DecodedMessage
Source code in faststream/nats/parser.py
37
38
39
40
41
async def decode_message(  # ruff: ignore[no-self-use]
    self,
    msg: "StreamMessage[Any]",
) -> "DecodedMessage":
    return decode_message(msg)