项目作者: Gr1N

项目描述 :
Python client for NATS messaging system
高级语言: Python
项目地址: git://github.com/Gr1N/nats-python.git
创建时间: 2018-08-30T19:09:02Z
项目社区:https://github.com/Gr1N/nats-python

开源协议:MIT License

下载


nats-python

Build Status codecov PyPI PyPI - Downloads

Python client for NATS messaging system.

This project is a replacement for abandoned pynats. nats-python supports only Python 3.6+ and fully covered with typings.

Go to the asyncio-nats project, if you’re looking for asyncio implementation.

Installation

  1. $ pip install nats-python

Usage

  1. from pynats import NATSClient
  2. with NATSClient() as client:
  3. # Connect
  4. client.connect()
  5. # Subscribe
  6. def callback(msg):
  7. print(f"Received a message with subject {msg.subject}: {msg}")
  8. client.subscribe(subject="test-subject", callback=callback)
  9. # Publish a message
  10. client.publish(subject="test-subject", payload=b"test-payload")
  11. # wait for 1 message
  12. client.wait(count=1)

Contributing

To work on the nats-python codebase, you’ll want to clone the project locally and install the required dependencies via poetry:

  1. $ git clone git@github.com:Gr1N/nats-python.git
  2. $ make install

To run tests and linters use command below:

  1. $ make lint && make test

If you want to run only tests or linters you can explicitly specify which test environment you want to run, e.g.:

  1. $ make lint-black

License

nats-python is licensed under the MIT license. See the license file for details.