Skip to main content

NATS App is wrapper client on NATS Connection

Project description

NATS App

pypi versions test Apache 2 licensed

NATS App is wrapper application on NATS Connection

Create NATS Application

NATS_URL = "nats://localhost:4222"

nc = NATSApp(NATS_URL)
await nc.connect()

Add RPC Handler

@nc.push_subscribe("app.test.echo", queue="worker")
async def rpc_func_echo(msg: Any) -> str:
    return f"Response with Msg.data: {msg.data}"

Call RPC

res = await nc.request("app.test.echo", {"args": ["test"]})
print(res)

JetStream push subscription

@nc.js_push_subscribe("app.test.js.subs", queue="worker")
async def handler(msg: Msg):
    print(msg.data)
    await msg.ack()

JetStream pull subscription

@nc.js_pull_subscribe("app.subject.js.subs", batch=1)
async def handler(msgs: list[Msg]):
    for m in msgs:
        print(m)
        await m.ack()

JetStream publish

await nc.js.publish("app.subject.js.subs", b"TEST123")

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

nats_app-0.2.1.tar.gz (15.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

nats_app-0.2.1-py3-none-any.whl (20.3 kB view details)

Uploaded Python 3

File details

Details for the file nats_app-0.2.1.tar.gz.

File metadata

  • Download URL: nats_app-0.2.1.tar.gz
  • Upload date:
  • Size: 15.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.1 CPython/3.12.9 Linux/6.8.0-1021-azure

File hashes

Hashes for nats_app-0.2.1.tar.gz
Algorithm Hash digest
SHA256 a9c7d86e98c0328df98e6494005fb482380569125fb194e503cee9773756cd91
MD5 b7e4ab45962dde6c5723cf7b5635c54d
BLAKE2b-256 b50b5b4a57ad122204ecb9542688ed7d79ebfb21e463decc77b20d392fe35ed6

See more details on using hashes here.

File details

Details for the file nats_app-0.2.1-py3-none-any.whl.

File metadata

  • Download URL: nats_app-0.2.1-py3-none-any.whl
  • Upload date:
  • Size: 20.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.1.1 CPython/3.12.9 Linux/6.8.0-1021-azure

File hashes

Hashes for nats_app-0.2.1-py3-none-any.whl
Algorithm Hash digest
SHA256 eeed5075daccb2b0d075f1eca5d6c1c08326eb2412f35c2d6c4d1d1da244027c
MD5 d61562f911dd878ee8d576e364ac6d59
BLAKE2b-256 24310447b1978887bb062d1f5bd0e64cbf85b30835fb75dbc65d84a71a392c9a

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page