Skip to content

NATS

NATS is an efficient, secure, open-source messaging system designed for cloud-native applications, IoT messaging, and microservices. Written in Go, NATS offers client libraries for many programming languages. It supports both At Most Once and At Least Once delivery and is versatile enough to run on large servers, cloud instances, edge gateways, and IoT devices.

Installation

Bash
pip install nats-py

Overview

To use the NATS transporter, pass the following options object to the create_microservice() method:

Python
from app_module import AppModule

from nestipy.core import NestipyFactory
from nestipy.microservice import MicroserviceOption, Transport

app = NestipyFactory.create_microservice(
    AppModule, [
        MicroserviceOption(
            transport=Transport.NATS,
            url="nats://localhost:4222"
        )
    ]
)

Client

Python
from nestipy.common import Module
from nestipy.microservice import ClientsModule, ClientsConfig, MicroserviceOption, Transport


@Module(
    imports=[
        ClientsModule.register([
            ClientsConfig(
                name="MATH_SERVICE",
                option=MicroserviceOption(
                    transport=Transport.NATS,
                    url="nats://localhost:4222"
                )
            )
        ]),
    ]
    ...
)
class AppModule:
    ...

Support us

Nestipy is a project released under the MIT license, meaning it's open source and freely available for use and modification. Its development thrives with the generous contributions of these fantastic individuals.