Skip to content

Commit 20963ae

Browse files
committed
Add nats-server package
Signed-off-by: Casper Beyer <[email protected]>
1 parent 4ad3792 commit 20963ae

File tree

12 files changed

+1554
-2
lines changed

12 files changed

+1554
-2
lines changed

.github/workflows/test.yml

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ on:
99
- "**"
1010

1111
jobs:
12-
test:
12+
nats:
1313
runs-on: ubuntu-latest
1414
timeout-minutes: 20
1515
env:
@@ -42,6 +42,45 @@ jobs:
4242
- name: Run tests
4343
run: |
4444
pipenv run flake8 --ignore="W391, W503, W504" ./nats/js/
45-
pipenv run pytest -x -vv -s --continue-on-collection-errors
45+
pipenv run pytest -x -vv -s --continue-on-collection-errors ./tests
4646
env:
4747
PATH: $HOME/nats-server:$PATH
48+
49+
project:
50+
name: ${{ matrix.project }} (python-${{ matrix.python-version }}, nats-server-${{ matrix.nats-server-version }}, ${{ matrix.os }})
51+
runs-on: ${{ matrix.os }}
52+
strategy:
53+
matrix:
54+
python-version: ["3.11", "3.12", "3.13"]
55+
os: ["ubuntu-latest", "macos-latest", "windows-latest"]
56+
nats-server-version: ["latest"]
57+
project: ["nats-server"]
58+
steps:
59+
- name: Checkout repository
60+
uses: actions/checkout@v5
61+
62+
- name: Set up Go
63+
uses: actions/setup-go@v6
64+
with:
65+
go-version: "stable"
66+
67+
- name: Install NATS Server
68+
run: |
69+
go install github.com/nats-io/nats-server/v2@${{ matrix.nats-server-version }}
70+
shell: bash
71+
72+
- name: Set up Python ${{ matrix.python-version }}
73+
uses: actions/setup-python@v6
74+
with:
75+
python-version: ${{ matrix.python-version }}
76+
77+
- name: Install uv
78+
uses: astral-sh/setup-uv@v6
79+
80+
- name: Install dependencies
81+
run: uv sync --dev
82+
working-directory: ${{ matrix.project }}
83+
84+
- name: Run tests for ${{ matrix.project }}
85+
run: uv run pytest -v -n auto
86+
working-directory: ${{ matrix.project }}

nats-server/.DS_Store

6 KB
Binary file not shown.

nats-server/README.md

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# NATS Server for Python
2+
3+
Manage NATS server instances from python.
4+
5+
## Features
6+
7+
- Asynchronous server control
8+
9+
## Installation
10+
11+
```bash
12+
pip install nats-server
13+
```
14+
15+
Requires Python 3.11+ and the NATS server binary in your PATH.
16+
17+
## Usage
18+
19+
```python
20+
import asyncio
21+
import nats.server
22+
23+
async def main():
24+
# Start server with auto port assignment
25+
server = await nats.server.run(port=0, jetstream=True)
26+
print(f"Server running on {server.host}:{server.port}")
27+
28+
# Do something with the server...
29+
# e.g connect with server.client_url
30+
31+
# Clean shutdown
32+
await server.shutdown()
33+
34+
asyncio.run(main())
35+
```
36+
37+
## License
38+
39+
MIT
40+
41+
## Contributing
42+
43+
Contributions welcome. Submit a Pull Request on GitHub.

nats-server/pyproject.toml

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
[build-system]
2+
requires = ["setuptools>=61.0"]
3+
build-backend = "setuptools.build_meta"
4+
5+
[project]
6+
name = "nats-server"
7+
version = "0.0.0"
8+
description = 'Python library for managing NATS servers for development and testing'
9+
readme = "README.md"
10+
requires-python = ">=3.11"
11+
license = "MIT"
12+
keywords = ["nats", "messaging", "testing"]
13+
authors = [
14+
{ name = "Casper Beyer", email = "[email protected]" },
15+
]
16+
classifiers = [
17+
"Development Status :: 4 - Beta",
18+
"Programming Language :: Python",
19+
"Programming Language :: Python :: 3.11",
20+
"Programming Language :: Python :: 3.12",
21+
"Programming Language :: Python :: 3.13",
22+
"Programming Language :: Python :: Implementation :: CPython",
23+
"Programming Language :: Python :: Implementation :: PyPy",
24+
]
25+
dependencies = []
26+
27+
[project.urls]
28+
Documentation = "https://github.com/nats-io/nats.py"
29+
Issues = "https://github.com/nats-io/nats.py/issues"
30+
Source = "https://github.com/nats-io/nats.py"
31+
32+
[tool.setuptools.packages.find]
33+
where = ["src"]
34+
35+
[tool.uv]
36+
dev-dependencies = [
37+
"pytest>=7.0.0",
38+
"pytest-asyncio>=0.21.0",
39+
"pytest-cov>=7.0.0",
40+
"pytest-xdist>=3.0.0",
41+
]
42+
43+
[tool.pytest.ini_options]
44+
asyncio_default_fixture_loop_scope = "function"
45+
asyncio_mode = "auto"
46+
47+
[tool.ruff.lint]
48+
ignore = ["TRY301", "S104"]

0 commit comments

Comments
 (0)