github nats-io/nats.py v2.13.0
Release v2.13.0

10 hours ago

Added

  • Add token callback support #812

    The token parameter on connect now accepts a callable that is invoked on
    each connection attempt, enabling dynamic token refresh on reconnect:

    def get_token():
        return fetch_token_from_auth_service()
    
    nc = await nats.connect("nats://localhost:4222", token=get_token)
  • Add per-message TTL support for KV operations #783

    KV create, delete, and purge now accept a msg_ttl parameter
    (in seconds). Requires nats-server 2.11+.

    kv = await js.create_key_value(bucket="SESSIONS")
    await kv.create("sess-123", b"user-data", msg_ttl=3600)
    await kv.delete("sess-123", msg_ttl=60)
  • Add consumer-configured inbox_prefix for JetStream pull_subscribe methods #781

    A custom inbox_prefix can be passed to pull_subscribe and
    pull_subscribe_bind to control the deliver subject prefix:

    sub = await js.pull_subscribe("orders.>", "my-consumer", inbox_prefix=b"_CUSTOM_INBOX.")
    msgs = await sub.fetch(10)
  • Add persist_mode to StreamConfig #773

  • Add raft_group, leader_since, and traffic_acc to ClusterInfo #766

Fixed

  • Fix StreamConfig omitempty fields for nats-server > 2.12 #788

Don't miss a new nats.py release

NewReleases is sending notifications on new releases.