Skip to content

PullSub

faststream.nats.PullSub #

PullSub(batch_size=1, timeout=5.0, batch=False)

A class to represent a NATS pull subscription.

PARAMETER DESCRIPTION
batch_size

Consuming messages batch size. (default is 1).

TYPE: int DEFAULT: 1

timeout

obj:float, optional): Wait this time for required batch size will be accumulated in stream in seconds (default is 5.0).

DEFAULT: 5.0

batch

Whether to propagate consuming batch as iterable object to your handler (default is False).

TYPE: bool DEFAULT: False

Source code in faststream/nats/schemas/pull_sub.py
def __init__(
    self,
    batch_size: int = 1,
    timeout: Optional[float] = 5.0,
    batch: bool = False,
) -> None:
    self.batch_size = batch_size
    self.batch = batch
    self.timeout = timeout

batch_size instance-attribute #

batch_size = batch_size

batch instance-attribute #

batch = batch

timeout instance-attribute #

timeout = timeout

validate classmethod #

validate(value)
Source code in faststream/nats/schemas/pull_sub.py
@classmethod
def validate(cls, value: Union[bool, "PullSub"]) -> Optional["PullSub"]:
    if value is True:
        return PullSub()
    elif value is False:
        return None
    else:
        return value