Skip to content

Commit 71b038d

Browse files
committed
More README.md updates.
1 parent 11f9df3 commit 71b038d

File tree

1 file changed

+28
-3
lines changed

1 file changed

+28
-3
lines changed

README.md

Lines changed: 28 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
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

2651
Also, our [tests](https://github.com/taskiq-python/natsrpy/tree/master/python/tests)
2752
are written in python and could be a good place to discover features and the way they intended to be used.

0 commit comments

Comments
 (0)