Skip to content

create_publisher

faststream.nats.publisher.factory.create_publisher #

create_publisher(
    *,
    subject: str,
    reply_to: str,
    headers: dict[str, str] | None,
    stream: Optional[JStream],
    timeout: float | None,
    broker_config: NatsBrokerConfig,
    schema_: Any | None,
    title_: str | None,
    description_: str | None,
    include_in_schema: bool,
) -> LogicPublisher
Source code in faststream/nats/publisher/factory.py
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
def create_publisher(
    *,
    subject: str,
    reply_to: str,
    headers: dict[str, str] | None,
    stream: Optional["JStream"],
    timeout: float | None,
    # Publisher args
    broker_config: "NatsBrokerConfig",
    # AsyncAPI args
    schema_: Any | None,
    title_: str | None,
    description_: str | None,
    include_in_schema: bool,
) -> LogicPublisher:
    publisher_config = NatsPublisherConfig(
        subject=subject,
        stream=stream,
        reply_to=reply_to,
        headers=headers,
        timeout=timeout,
        _outer_config=broker_config,
    )

    specification = NatsPublisherSpecification(
        _outer_config=broker_config,
        specification_config=NatsPublisherSpecificationConfig(
            subject=subject,
            schema_=schema_,
            title_=title_,
            description_=description_,
            include_in_schema=include_in_schema,
        ),
    )

    return LogicPublisher(publisher_config, specification)