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.1.4.tar.gz (15.9 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.1.4-py3-none-any.whl (20.1 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: nats_app-0.1.4.tar.gz
  • Upload date:
  • Size: 15.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.5 CPython/3.12.8 Linux/6.5.0-1025-azure

File hashes

Hashes for nats_app-0.1.4.tar.gz
Algorithm Hash digest
SHA256 649ab90aa868783938d3bdcc98b43b4aa2f4446299d2cbf59c4e1173b02b238f
MD5 8b29264f0e719c43d0ec296ee4b9b957
BLAKE2b-256 5d7ff9a9f297c7b7ff87b9827b12e7b44e7b8b8c0e26c75595c6778bc9bc5bc2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: nats_app-0.1.4-py3-none-any.whl
  • Upload date:
  • Size: 20.1 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.8.5 CPython/3.12.8 Linux/6.5.0-1025-azure

File hashes

Hashes for nats_app-0.1.4-py3-none-any.whl
Algorithm Hash digest
SHA256 306c05098020aead971e5d6ef3d66e5c6f6fa2cc239f509ef734538a44cbf13f
MD5 a3d70f5f22927526c368df46f76866ea
BLAKE2b-256 485cd8d78f239e75a00d0d0133ccd1cc76d25f9291cbe4e686f01ed5800ff6fc

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