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

latest releases: v2.9.0, v2.8.0
8 months ago
  • Added heartbeat option to pull subscribers fetch API

    await sub.fetch(1, timeout=1, heartbeat=0.1)

    It can be useful to help distinguish API timeouts from not receiving messages:

    try:
      await sub.fetch(100, timeout=1, heartbeat=0.2)
    except nats.js.errors.FetchTimeoutError:
      # timeout due to not receiving messages
    except asyncio.TimeoutError:
      # unexpected timeout
  • Added subject_transform to add_consumer

    await js.add_stream(
      name="TRANSFORMS",
      subjects=["test", "foo"],
      subject_transform=nats.js.api.SubjectTransform(
        src=">", dest="transformed.>"
      ),
    )
  • Added subject_transform to sources as well:

    transformed_source = nats.js.api.StreamSource(
        name="TRANSFORMS",
        # The source filters cannot overlap.
        subject_transforms=[
            nats.js.api.SubjectTransform(
                src="transformed.>", dest="fromtest.transformed.>"
            ),
            nats.js.api.SubjectTransform(
                src="foo.>", dest="fromtest.foo.>"
            ),
        ],
    )
    await js.add_stream(
      name="SOURCING",
      sources=[transformed_source],
    )
  • Added backoff option to add_consumer

    await js.add_consumer(
              "events",
              durable_name="a",
              max_deliver=3,    # has to be greater than length as backoff array
              backoff=[1, 2],   # defined in seconds
              ack_wait=999999,  # ignored once using backoff
              max_ack_pending=3,
              filter_subject="events.>",
          )
  • Added compression to add_consumer

    await js.add_stream(
      name="COMPRESSION",
      subjects=["test", "foo"],
      compression="s2",
    )
  • Added metadata to add_stream

    await js.add_stream(
        name="META",
        subjects=["test", "foo"],
        metadata={'foo': 'bar'},
    )

Don't miss a new nats.py release

NewReleases is sending notifications on new releases.