Skip to content

Releases: nats-io/nats.py2

Release v0.8.4

27 Feb 00:03
Compare
Choose a tag to compare

Fixed

  • Handle all exceptions on reconnect (#64)
pip install nats-client==0.8.4

Release v0.8.2

27 Feb 00:05
579494e
Compare
Choose a tag to compare

Fixed

  • Fix request with multiple responses dropping messages (#60)

Release v0.8.0

22 Sep 17:51
f271ca8
Compare
Choose a tag to compare

Major version update of the client with internals reworked a lot in order to have structure and API similar to the Asyncio NATS client for Python3.

Includes several bugfixes for reconnection logic, ping interval and flush API, Tornado 5.X support and newer features such as no echo and drain mode support.

Added

  • Drain API (#56)

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

    import tornado.gen
    import tornado.concurrent
    
    from nats.io import Client as NATS
    from nats.io.errors import ErrNoServers
    from tornado.ioloop import IOLoop as loop
    
    @tornado.gen.coroutine
    def main():
      nc = NATS()
    
      conn_closed = tornado.concurrent.Future()
    
      def closed_cb():
        conn_closed.set_result(True)
    
      # Set pool servers in the cluster and give a name to the client.
      yield nc.connect("127.0.0.1:4222", closed_cb=closed_cb)
    
      @tornado.gen.coroutine
      def handler(msg):
        # Can check whether client is in draining state
        if nc.is_draining:
            print("[Status  ] Draining, will disconnect soon...")
    
        print("[Received] {}".format(msg.data))
        yield nc.publish(msg.reply, b'I can help')
    
      yield nc.subscribe("help", "workers", cb=handler)
    
      responses = []
    
      @tornado.gen.coroutine
      def send_requests():
        # Send 100 async requests and wait for all the responses.
        for i in range(0, 1000):
          try:
            response = yield nc.request("help", '[{}] help!'.format(i), timeout=0.1)
            responses.append(response)
          except:
            break
    
      loop.current().spawn_callback(send_requests)
      yield tornado.gen.sleep(1)
    
      # Gracefully close the connection and wait for closed callback to be signaled.
      yield nc.drain()
      yield conn_closed
    
      print("Received {} responses".format(len(responses)))
    
    if __name__ == '__main__':
        loop.current().run_sync(main)
  • No echo mode (#55)

    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.

    yield ncA.connect(no_echo=True)
    yield ncB.connect()
    
    @tornado.gen.coroutine
    def handler(msg):
      # Messages sent by `ncA' will not be received.
      print("[Received] ", msg)
    
    yield ncA.subscribe("greetings", cb=handler)
    yield ncA.publish("greetings", b'Hello World!')
    yield ncB.publish("greetings", b'Hello World!')
  • User, Password and Auth Token options (#57)

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

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

Improved

  • Improved connect API using URLs like in the Go client (#54)

    Now possible to connect to a NATS cluster with any of the following ways:

    # 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.
    yield nc.connect("demo.nats.io")
    
    # TLS example
    await nc.connect("tls://demo.nats.io:4443")

Fixed

  • Fixed error callback not being called on connect errors (#50)

  • Fixed client not stopping to reconnect against servers after authorization failed more than max_reconnect_attempts (#51)

  • Fixed calling close callback whenever the TCP connection was disconnected.
    Now it will only be called once when the client disconnects and gives up connecting to NATS (#51)

  • Fixed issue when multiple Flush calls would result in unexpected disconnections (3aa4463)

Changed

  • Updated client to work with Tornado 5.X series, which is last version to be compatible with Python 2 (#53)

Deprecated

  • io_loop usage which has been deprecated in Tornado 5.X
  • close_cb is deprecated and recommended to use closed_cb instead to be consistent with the Asyncio NATS client

Release v0.7.2

11 Jul 17:13
a76123a
Compare
Choose a tag to compare

Minor version update to handle changes in latest NATS v1.2.0

Fixed

Connection fails if tls_required field missing from INFO block #46

Release v0.7.0

13 Jun 21:47
Compare
Choose a tag to compare

Added

  • Cluster Auto Discovery support (#39)

  • request method when not passed a callback now returns a future that can be awaited for the result which would be the message. When passed a callback it still works asynchronously.

  • request now uses a single async wildcard subscription for handling the responses

  • Inboxes now use the NUID for the identifiers #41

Fixed

  • Don't call error callback in read loop if connection was closed (#40) | thanks @brianshannan-wf

  • Fixes not throwing away subscriptions on close and auto unsubscribe (116b6f6)

Changed

  • New implementation of Request/Response, now less chatty over the network (#43)

  • Each subscription now spawns a callback for processing the messages using a tornado queue to which the messages are buffered. (d65f470)
    The pending queue can be customized with new pending_msgs_limit and pending_bytes_limit options on subscribe. (defaults being 65536 and 65536*1024 respectively).
    When the tornado queue is full an async ErrSlowConsumer error is thrown to the error_handler if it is set

Release v0.6.0

04 May 14:48
Compare
Choose a tag to compare

Fixed

  • Delays IOLoop creation, allowing the library to be usable on Multi-process Tornado Server (#37)

  • Flusher reconnection fixes (#35)

  • Recover from flush timeouts on lost PING-PONG message (#36)

Release v0.5.6

24 Jan 21:46
Compare
Choose a tag to compare

Added

  • Support for auth token authentication (#25)

Changed

  • Relaxed version of tornado (#27)

Release v0.5.4

23 Aug 17:22
Compare
Choose a tag to compare

Major bug fixes in flusher logic and flush APIs which would cause published commands to be dropped (#23 | #24)

https://pypi.python.org/pypi/nats-client/0.5.4

Release v0.5.2

17 Jul 21:23
Compare
Choose a tag to compare

Minor bugfix release to be more tolerant for large protocol lines #19

Release v0.5.0

26 Mar 00:32
Compare
Choose a tag to compare

Mostly bug fixes but changes to reconnection logic so bumping to major version:

  • Fixes to publish_request API which was not calling flushing like publish (#16)
  • Fixes to max_reconnect_attempts to enable infinite reconnects by setting it to -1 (#17)
  • Fixes to stopping of ping interval on disconnections (#12)
  • Added reconnect_time_wait to set the time to back off before trying to reconnect to a server (#17)

https://pypi.python.org/pypi/nats-client/0.5.0