Releases: nats-io/nats.py2
Release v0.8.4
Release v0.8.2
Fixed
- Fix request with multiple responses dropping messages (#60)
Release v0.8.0
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.Xclose_cb
is deprecated and recommended to useclosed_cb
instead to be consistent with the Asyncio NATS client
Release v0.7.2
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
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 newpending_msgs_limit
andpending_bytes_limit
options onsubscribe
. (defaults being 65536 and 65536*1024 respectively).
When the tornado queue is full an asyncErrSlowConsumer
error is thrown to theerror_handler
if it is set
Release v0.6.0
Release v0.5.6
Release v0.5.4
Release v0.5.2
Minor bugfix release to be more tolerant for large protocol lines #19
Release v0.5.0
Mostly bug fixes but changes to reconnection logic so bumping to major version:
- Fixes to
publish_request
API which was not calling flushing likepublish
(#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)