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.7.6.tar.gz (21.0 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.7.6-py3-none-any.whl (27.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: nats_app-0.7.6.tar.gz
  • Upload date:
  • Size: 21.0 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.12.12 Linux/6.11.0-1018-azure

File hashes

Hashes for nats_app-0.7.6.tar.gz
Algorithm Hash digest
SHA256 ce9ba48e1ff732d98320c1e3e84bf569e2ab054d36db97e7e4937744e6fa38f3
MD5 818d6a8fe4f51904817baa6827c73949
BLAKE2b-256 cef275e089dbdab4eba9d1bf247fd05d4d68fe9ded2591cb8c3ec46a174d3a90

See more details on using hashes here.

File details

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

File metadata

  • Download URL: nats_app-0.7.6-py3-none-any.whl
  • Upload date:
  • Size: 27.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/2.2.1 CPython/3.12.12 Linux/6.11.0-1018-azure

File hashes

Hashes for nats_app-0.7.6-py3-none-any.whl
Algorithm Hash digest
SHA256 f61bfde3936d7016fe2c7a7e11e8819459cbcbb3660a4a772b04d27a9ce6c549
MD5 6b33f286b769c3a14140bb76598e4d1c
BLAKE2b-256 2e6a4f5f87dfb5cd672d681487c1041776e8045d4f77598f7ca19a3eb8425e24

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