Skip to content

Releases: nats-io/nats.py

Release v0.11.2

14 Sep 15:35
7360df6
Compare
Choose a tag to compare

Added

  • Error callback is now added by default (#170)

Fixed

  • Fixed drain timeout error after using request (#171)

Release v0.11.0

09 Sep 21:40
624e63b
Compare
Choose a tag to compare

Added

  • Added ability to access the connection identifier / client id (#146)
print(nc.client_id)
  • Added option to specify tls_hostname (#157)
await nc.connect(servers=["tls://127.0.0.1:4443"], loop=loop, tls=ssl_ctx, tls_hostname="localhost")

Fixed

  • Fixed drain non-callback subscriptions correctly (#147)
  • Fixed cleaning up subscriptions in the event of a timeout (#156)
  • Fixed TLS upgrade method, uvloop TLS now supported (#164)
  • Fixed waiting for all messages to be processed while draining (#165)
  • Fixed pending byte/msg limits can't be disabled with -1 as it can in other clients ()
  • Fixed following connect_timeout in TLS connections (5d7e01c)
  • Fixed set outstanding pings to zero when a pong is received 84c6d9a
  • Fixed support for auto unsubscribe (bf881ae)

Improved

  • Raise ErrInvalidCallbackType error when client callback functions are not coroutines (#128)
  • Many yapf formatting fixes (#152)
  • Fixed deprecation warnings. Remove unnecessary coverage runs. (#149)

Changed

  • Testing againts NATS 2.1.8
  • Updated examples to async/await syntax
  • Client uses f strings (#152)

Deprecated

  • Deprecated support for Python 3.5. Next release will drop support for Python 3.6.

Release v0.9.2

31 May 20:45
7ad8e54
Compare
Choose a tag to compare

Added

Add nkeys_seed option to be able to connect to server that supports nkeys based auth.

    await nc.connect(
        "tls://127.0.0.1:4222",
        nkeys_seed="./path/to/nkeys/user.nk",
    )

Fixed

  • Fixes handling permissions violation errors and call error cb when they occur in case it is configured.

Release v0.9.0

14 May 19:25
1acca35
Compare
Choose a tag to compare

Added

  • Added support for NKEYS/JWT for NATS v2 new auth features. The nkeys dependency is optional and can be installed via pip as an extra package: pip install asyncio-nats-client[nkeys].

Usage:

await nc.connect(
    "tls://connect.ngs.global:4222",
    user_credentials="./tests/nkeys/user.creds"
)
await nc.connect(
    "tls://connect.ngs.global:4222",
    user_credentials=(
      "./tests/nkeys/user.jwt", "./tests/nkeys/user.nk"
    )
)
  • Added support for functools partials to subscriptions
async def subscription_handler(arg1, msg):
    print(arg1)
    msgs.append(msg)

partial_sub_handler = functools.partial(subscription_handler, "example")
await nc.subscribe("foo", cb=partial_sub_handler)
  • Added Pipfile to the repo to adopt pipenv based flow

  • Added support to connect securely with TLS to implicit ips (c5b1f4e)

Fixed

  • Fixed issue when using verbose mode (#93)

Changed

  • Changed Repo name is now nats.py like other NATS clients.
  • Adopted yapf for formatting
  • Changed testing pytest is now used to run the tests

Deprecated

  • Removed tests/test.py since no longer used

Release v0.8.2

17 Sep 18:38
a370dcc
Compare
Choose a tag to compare

Added

  • Support using tls scheme to setup default context to connect securely (#88)
    await nc.connect("tls://demo.nats.io:4443")
    await nc.connect(servers=["tls://demo.nats.io:4443"])

Example using nats-pub & nats-sub:

$ python3.7 examples/nats-pub -s tls://demo.nats.io:4443 hello -d world
...

$ python3.7 examples/nats-sub -s tls://demo.nats.io:4443 hello 
Connected to NATS at demo.nats.io:4443...
Received a message on 'hello ': world

If using Python 3.7 in OS X and getting SSL errors, run first the following to install the certifi default certs:

/Applications/Python\ 3.7/Install\ Certificates.command

Release v0.8.0

24 Aug 20:17
30ee515
Compare
Choose a tag to compare

Added

  • Support for drain mode (#82)

    This feature allows clients to gracefully disconect, letting the subscribers
    handle any inflight messages that may have been sent by the server already.

    async def handler(msg):
      print("[Received] ", msg)
      await nc.publish(msg.reply, b'I can help')
    
      # Can check whether client is in draining state
      if nc.is_draining:
        print("Connection is draining")
    
    await nc.subscribe("help", "workers", cb=handler)
    
    requests = []
    for i in range(0, 1000):
        request = nc.request("help", b'help!', 0.2)
        requests.append(request)
    
    # Wait for all the responses
    responses = await asyncio.gather(*requests)
    print("Received {} responses", len(responses))
    
    # Gracefully close the connection.
    await nc.drain()

    Example usage can be found at:
    https://github.com/nats-io/asyncio-nats/blob/e1996e7c4ae30daa63c49af20700d42fad1bd2f2/examples/drain-sub.py

  • Support for no_echo mode (#74)

    When connected to a NATS Server v1.2.0 or above, a client can now opt to avoid
    receiving messages that it itself has published.

    await ncA.connect(no_echo=True)
    await ncB.connect()
    
    async def handler(msg):
      # Messages sent by `ncA' will not be received.
      print("[Received] ", msg)
    
    await ncA.subscribe("greetings", cb=handler)
    await ncA.publish("greetings", b'Hello World!')
    await ncB.publish("greetings", b'Hello World!')
  • Added connect_timeout option to disconnect from unhealthy servers in the pool (https://github.com/nats-io/asyncio-nats/pull/83/files)

    # Give up if can't connect to a server in 5 seconds
    await nc.connect("demo.nats.io:4222", connect_timeout=5)
  • Added loop parameter to connect to set the event loop like in asyncio APIs

    await nc.connect("demo.nats.io", loop=asyncio.new_event_loop())

Improved

  • connect API is now modeled to work more closely to how the Go client works:

    # Assume 'nats://' scheme
    await nc.connect("demo.nats.io:4222")
    
    # Complete with scheme a la Go client classic usage.
    await nc.connect("nats://demo.nats.io:4222")
    
    # Use default 4222 port.
    await nc.connect("demo.nats.io")
    
    # Explicit cluster list
    await nc.connect(servers="demo.nats.io")

Fixed

  • Examples and tests now support Python 3.7 (#71)

  • Added user, password, token parameters to set the auth credentials for servers that were discovered implicitly. (f8c28b3)

    # Set user and info credentials
    await nc.connect("127.0.0.1:4222", user="foo", password="bar")
    
    # Token
    await nc.connect("127.0.0.1:4222", token="secretoken")

Changed

  • Examples were changed to use async/ await instead of asyncio.coroutine and yield from (e1996e7)

Deprecated

  • Removed Python 3.4 from build (b2ee929)

  • Tests are now using async/await syntax throughout (#78)
    In the next v1.0 release client will be solely using async/await syntax (#68)

Release v0.7.2

19 Jul 15:55
Compare
Choose a tag to compare

Fixed

  • Improve behavior of reconnection logic (#67)

  • Issue with tasks left pending after calling close() (#69)

Release v0.7.0

04 Apr 22:44
Compare
Choose a tag to compare

Added

  • New style request/response implementation (#59)

  • The ErrSlowConsumer now include sid and subject when a message is dropped (#58)

  • New options pending_msgs_limit and pending_bytes_limit were added to subscribe API
    for controlling limits of pending data waiting to be processed before dropping messages.
    (#58)

  • Msg type now uses __slots__ (#58)

Improved

  • More performant inbox generation via NUID approach (#57)

Fixed

  • Each Subscription now has a task so coroutines no longer
    cause head of line blocking to each other.
    (#58)

Changed

  • request API when a callback is not passed now blocks and waits for response
    using the new style request/response API which is less chatty over
    the network.
    (#59)

Deprecated

  • subscribe_async will be deprecated in next release,
    as a workaround a task can be created inside of a handler and would
    result in more control than can have in the library.

Release v0.6.4

06 Dec 13:45
Compare
Choose a tag to compare

Fixed

  • Fix to issue of connection being closed when upgrading to TLS (#49)
  • Fix to cancel pending reconnection task when closing connection (#50)

Release v0.6.2

20 Nov 03:37
Compare
Choose a tag to compare

Fixed

  • Fix allow_reconnect to bail connecting on errors during after first connect (#48)
  • Fix error handling when server does not respond with properly formed INFO line on connect (#47 , #44)
  • Fix checks for keys in INFO line and use defaults if not present (#48)