File tree Expand file tree Collapse file tree 1 file changed +28
-3
lines changed
Expand file tree Collapse file tree 1 file changed +28
-3
lines changed Original file line number Diff line number Diff line change 1- [ ![ PyPI] ( https://img.shields.io/pypi/v/natsrpy?style=for-the-badge )] ( https://pypi.org/project/scyllapy / )
2- [ ![ PyPI - Downloads] ( https://img.shields.io/pypi/dm/natsrpy?style=for-the-badge )] ( https://pypistats.org/packages/scyllapy )
1+ [ ![ PyPI] ( https://img.shields.io/pypi/v/natsrpy?style=for-the-badge )] ( https://pypi.org/project/natsrpy / )
2+ [ ![ PyPI - Downloads] ( https://img.shields.io/pypi/dm/natsrpy?style=for-the-badge )] ( https://pypistats.org/packages/natsrpy )
33
44# Nats client
55
@@ -21,7 +21,32 @@ Or alternatively you can build it yourself using maturin, and stable rust.
2121
2222## Usage
2323
24- You can see usage examples in our [ examples] ( https://github.com/taskiq-python/natsrpy/tree/master/examples ) folder.
24+ ``` python
25+ import asyncio
26+
27+ from natsrpy import Nats
28+
29+ async def main () -> None :
30+ nats = Nats([" nats://localhost:4222" ])
31+ await nats.startup()
32+
33+ subscription = await nats.subscribe(" hello" )
34+
35+ await nats.publish(" hello" , " str world" )
36+
37+ subscription.unsubscribe(limit = 1 )
38+ async for message in subscription:
39+ print (message)
40+
41+ # Don't forget to call shutdown.
42+ await nats.shutdown()
43+
44+
45+ if __name__ == " __main__" :
46+ asyncio.run(main())
47+ ```
48+
49+ You can see more usage examples in our [ examples] ( https://github.com/taskiq-python/natsrpy/tree/master/examples ) folder.
2550
2651Also, our [ tests] ( https://github.com/taskiq-python/natsrpy/tree/master/python/tests )
2752are written in python and could be a good place to discover features and the way they intended to be used.
You can’t perform that action at this time.
0 commit comments