Skip to content

PubAck

nats.js.api.PubAck dataclass #

PubAck(stream, seq, domain=None, duplicate=None)

Bases: Base

PubAck is the response of publishing a message to JetStream.

stream instance-attribute #

stream

seq instance-attribute #

seq

domain class-attribute instance-attribute #

domain = None

duplicate class-attribute instance-attribute #

duplicate = None

from_response classmethod #

from_response(resp)

Read the class instance from a server response.

Unknown fields are ignored ("open-world assumption").

Source code in nats/js/api.py
@classmethod
def from_response(cls: type[_B], resp: Dict[str, Any]) -> _B:
    """Read the class instance from a server response.

    Unknown fields are ignored ("open-world assumption").
    """
    params = {}
    for field in fields(cls):
        if field.name in resp:
            params[field.name] = resp[field.name]
    return cls(**params)

evolve #

evolve(**params)

Return a copy of the instance with the passed values replaced.

Source code in nats/js/api.py
def evolve(self: _B, **params) -> _B:
    """Return a copy of the instance with the passed values replaced."""
    return replace(self, **params)

as_dict #

as_dict()

Return the object converted into an API-friendly dict.

Source code in nats/js/api.py
def as_dict(self) -> Dict[str, object]:
    """Return the object converted into an API-friendly dict."""
    result = {}
    for field in fields(self):
        val = getattr(self, field.name)
        if val is None:
            continue
        if isinstance(val, Base):
            val = val.as_dict()
        if isinstance(val, list):
            if len(val) > 0 and isinstance(val[0], Base):
                val = [v.as_dict() for v in val if isinstance(v, Base)]
        result[field.name] = val
    return result