# Nats plugin for Streamz
This a plugin for [Streamz](https://github.com/python-streamz/streamz) that
adds stream nodes for writing and reading data from/to
[NATS](https://github.com/nats-io/nats.py).
## 🛠 Installation
Latest stable version is available on PyPI
```sh
pip install streamz_nats
```
Latest development version can be installed from git repo
```sh
pip install git+https://github.com/MarekWadinger/streamz_nats
```
## ⚡️ Quickstart
To start working with streamz_nats, follow these 3 steps:
### 1. Run a standalone NATS cluster locally
```sh
docker run -t -d -p 4222:4222 --name streamz-nats nats:latest
```
### 2. Create a consumer
The following example creates a consumer of the `greet.*` topics, where `*` is
wildcard for any substring, receives incoming messages, prints the content and
ID of messages that arrive, and acknowledges each message to the Pulsar broker.
```python
import nats
from streamz import Stream
s = Stream.from_nats(
'nats://localhost:4222',
['greet.*'],
)
s.map(lambda x: x.decode())
L = s.sink_to_list()
s.start()
while True:
try:
if L:
print(L.pop(-1))
```
Raw data
{
"_id": null,
"home_page": "https://github.com/MarekWadinger/streamz_nats",
"name": "streamz-nats",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.7.2,<4.0.0",
"maintainer_email": "",
"keywords": "streamz,nats",
"author": "Marek Wadinger",
"author_email": "marekwadinger@icloud.com",
"download_url": "",
"platform": null,
"description": "# Nats plugin for Streamz\n\nThis a plugin for [Streamz](https://github.com/python-streamz/streamz) that\nadds stream nodes for writing and reading data from/to\n[NATS](https://github.com/nats-io/nats.py).\n\n## \ud83d\udee0 Installation\n\nLatest stable version is available on PyPI\n\n```sh\npip install streamz_nats\n```\n\nLatest development version can be installed from git repo\n\n```sh\npip install git+https://github.com/MarekWadinger/streamz_nats\n```\n\n## \u26a1\ufe0f Quickstart\n\nTo start working with streamz_nats, follow these 3 steps:\n\n### 1. Run a standalone NATS cluster locally\n\n```sh\ndocker run -t -d -p 4222:4222 --name streamz-nats nats:latest\n```\n\n### 2. Create a consumer\n\nThe following example creates a consumer of the `greet.*` topics, where `*` is\nwildcard for any substring, receives incoming messages, prints the content and\nID of messages that arrive, and acknowledges each message to the Pulsar broker.\n\n```python\nimport nats\nfrom streamz import Stream\n\ns = Stream.from_nats(\n 'nats://localhost:4222',\n ['greet.*'],\n )\n\ns.map(lambda x: x.decode())\nL = s.sink_to_list()\n\ns.start()\nwhile True:\n try:\n if L:\n print(L.pop(-1))\n```\n",
"bugtrack_url": null,
"license": "",
"summary": "",
"version": "0.1.0",
"project_urls": {
"Homepage": "https://github.com/MarekWadinger/streamz_nats",
"Repository": "https://github.com/MarekWadinger/streamz_nats"
},
"split_keywords": [
"streamz",
"nats"
],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "b4d1cb7628fcfe573675e39a61ee50f0c6d3816a8c1d9c45f2c3688c3303f9d1",
"md5": "ccd79fc517ed40eed3e2f73c5aa8dc5e",
"sha256": "5c8c4177624411d5cff465545e1e049f736c03e98bf72fe3e6e2d37cfdbb2bad"
},
"downloads": -1,
"filename": "streamz_nats-0.1.0-py3-none-any.whl",
"has_sig": false,
"md5_digest": "ccd79fc517ed40eed3e2f73c5aa8dc5e",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7.2,<4.0.0",
"size": 3927,
"upload_time": "2023-10-16T13:46:02",
"upload_time_iso_8601": "2023-10-16T13:46:02.718977Z",
"url": "https://files.pythonhosted.org/packages/b4/d1/cb7628fcfe573675e39a61ee50f0c6d3816a8c1d9c45f2c3688c3303f9d1/streamz_nats-0.1.0-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-10-16 13:46:02",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "MarekWadinger",
"github_project": "streamz_nats",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "streamz-nats"
}