stompman 0.6.2__tar.gz → 0.6.3__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1 @@
1
+ .venv
@@ -0,0 +1,11 @@
1
+ version: 2
2
+ updates:
3
+ - package-ecosystem: github-actions
4
+ directory: /
5
+ schedule:
6
+ interval: monthly
7
+
8
+ - package-ecosystem: pip
9
+ directory: /
10
+ schedule:
11
+ interval: monthly
@@ -0,0 +1,24 @@
1
+ name: Publish
2
+
3
+ on:
4
+ release:
5
+ types:
6
+ - published
7
+
8
+ jobs:
9
+ publish:
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - uses: actions/checkout@v4
13
+ - uses: actions/setup-python@v5
14
+ with:
15
+ python-version: "3.12"
16
+ - uses: actions/cache@v4
17
+ with:
18
+ path: ~/.cache/uv
19
+ key: publish-${{ hashFiles('pyproject.toml') }}
20
+ - uses: extractions/setup-just@v2
21
+ - run: curl -LsSf https://astral.sh/uv/install.sh | sh
22
+ - run: just publish
23
+ env:
24
+ PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }}
@@ -0,0 +1,82 @@
1
+ name: Test
2
+
3
+ on:
4
+ push:
5
+ branches:
6
+ - main
7
+
8
+ pull_request:
9
+
10
+ concurrency:
11
+ group: ${{ github.head_ref || github.run_id }}
12
+ cancel-in-progress: true
13
+
14
+ env:
15
+ DEFAULT_PYTHON_VERSION: "3.12"
16
+
17
+ jobs:
18
+ check-types:
19
+ runs-on: ubuntu-latest
20
+ steps:
21
+ - uses: actions/checkout@v4
22
+ - uses: actions/setup-python@v5
23
+ with:
24
+ python-version: ${{ env.DEFAULT_PYTHON_VERSION }}
25
+ - uses: actions/cache@v4
26
+ with:
27
+ path: ~/.cache/uv
28
+ key: check-types-${{ hashFiles('pyproject.toml') }}
29
+ - run: curl -LsSf https://astral.sh/uv/install.sh | sh
30
+ - uses: extractions/setup-just@v2
31
+ - run: just install check-types
32
+
33
+ lint:
34
+ runs-on: ubuntu-latest
35
+ steps:
36
+ - uses: actions/checkout@v4
37
+ - uses: actions/setup-python@v5
38
+ with:
39
+ python-version: ${{ env.DEFAULT_PYTHON_VERSION }}
40
+ - uses: actions/cache@v4
41
+ with:
42
+ path: ~/.cache/uv
43
+ key: lint-${{ hashFiles('pyproject.toml') }}
44
+ - run: curl -LsSf https://astral.sh/uv/install.sh | sh
45
+ - uses: extractions/setup-just@v2
46
+ - run: just install lint
47
+
48
+ test:
49
+ runs-on: ubuntu-latest
50
+ strategy:
51
+ fail-fast: false
52
+ matrix:
53
+ python-version:
54
+ - "3.11"
55
+ - "3.12"
56
+ steps:
57
+ - uses: actions/checkout@v4
58
+ - uses: actions/setup-python@v5
59
+ with:
60
+ python-version: ${{ matrix.python-version }}
61
+ - uses: actions/cache@v4
62
+ with:
63
+ path: ~/.cache/uv
64
+ key: ${{ github.job }}-${{ matrix.python-version }}-${{ hashFiles('pyproject.toml') }}
65
+ - run: curl -LsSf https://astral.sh/uv/install.sh | sh
66
+ - uses: extractions/setup-just@v2
67
+ - run: just install test -vv
68
+
69
+ test-integration:
70
+ runs-on: ubuntu-latest
71
+ strategy:
72
+ fail-fast: false
73
+ matrix:
74
+ python-version:
75
+ - "3.11"
76
+ - "3.12"
77
+ steps:
78
+ - uses: actions/checkout@v4
79
+ - uses: extractions/setup-just@v2
80
+ - run: just test-integration
81
+ env:
82
+ PYTHON_VERSION: ${{ matrix.python-version }}
@@ -0,0 +1,4 @@
1
+ .coverage
2
+ .venv
3
+ dist
4
+ uv.lock
@@ -0,0 +1,15 @@
1
+ ARG PYTHON_VERSION
2
+ FROM python:${PYTHON_VERSION}-slim-bullseye
3
+
4
+ # hadolint ignore=DL3013, DL3042
5
+ RUN --mount=type=cache,target=~/.cache/pip pip install uv
6
+
7
+ WORKDIR /app
8
+ COPY pyproject.toml .
9
+ RUN uv lock
10
+
11
+ COPY stompman/__init__.py stompman/__init__.py
12
+ COPY README.md .
13
+ RUN --mount=type=cache,target=~/.cache/uv uv sync
14
+
15
+ COPY . .
@@ -0,0 +1,35 @@
1
+ default: install lint check-types test test-integration
2
+
3
+ install:
4
+ uv -q lock
5
+ uv -q sync
6
+
7
+ test *args:
8
+ uv -q run pytest {{args}}
9
+
10
+ lint:
11
+ uv -q run ruff check .
12
+ uv -q run ruff format .
13
+
14
+ check-types:
15
+ uv -q run mypy .
16
+
17
+ run-artemis:
18
+ docker compose up
19
+
20
+ run-consumer:
21
+ uv -q run python testing/consumer.py
22
+
23
+ run-producer:
24
+ uv -q run python testing/producer.py
25
+
26
+ test-integration *args:
27
+ #!/bin/bash
28
+ trap 'echo; docker compose down --remove-orphans' EXIT
29
+ docker compose run --build --rm app .venv/bin/pytest tests/integration.py --no-cov {{args}}
30
+
31
+ publish:
32
+ rm -rf dist/*
33
+ uv tool run --from build python -- -m build --installer uv
34
+ uv tool run twine check dist/*
35
+ uv tool run twine upload dist/* --username __token__ --password $PYPI_TOKEN
@@ -1,23 +1,18 @@
1
- Metadata-Version: 2.1
1
+ Metadata-Version: 2.3
2
2
  Name: stompman
3
- Version: 0.6.2
3
+ Version: 0.6.3
4
4
  Summary: Python STOMP client with pleasant API
5
- Home-page: https://github.com/vrslev/stompman
5
+ Project-URL: repository, https://github.com/vrslev/stompman
6
+ Author-email: Lev Vereshchagin <mail@vrslev.com>
6
7
  License: MIT
7
- Keywords: stomp,artemis,activemq,messaging,jms
8
- Author: Lev Vereshchagin
9
- Author-email: mail@vrslev.com
10
- Requires-Python: >=3.11,<4.0
8
+ License-File: LICENSE
9
+ Keywords: activemq,artemis,jms,messaging,stomp
11
10
  Classifier: Development Status :: 4 - Beta
12
- Classifier: License :: OSI Approved :: MIT License
13
11
  Classifier: Natural Language :: English
14
- Classifier: Programming Language :: Python :: 3
15
- Classifier: Programming Language :: Python :: 3.11
16
- Classifier: Programming Language :: Python :: 3.12
17
12
  Classifier: Programming Language :: Python :: Implementation :: CPython
18
13
  Classifier: Topic :: System :: Networking
19
14
  Classifier: Typing :: Typed
20
- Project-URL: Repository, https://github.com/vrslev/stompman
15
+ Requires-Python: >=3.11
21
16
  Description-Content-Type: text/markdown
22
17
 
23
18
  # stompman
@@ -37,6 +32,7 @@ Before you start using stompman, make sure you have it installed:
37
32
  ```sh
38
33
  pip install stompman
39
34
  poetry add stompman
35
+ uv add stompman
40
36
  ```
41
37
 
42
38
  Initialize a client:
@@ -163,4 +159,3 @@ Also, I want to pointed out that:
163
159
  ## No docs
164
160
 
165
161
  I try to keep it simple and easy to understand. May be counter-intuitive for some, but concise high-quality code speaks for itself. There're no comments and little indirection. Read the source if you wish, leave an issue if it's not enough or you want to add or fix something.
166
-
@@ -15,6 +15,7 @@ Before you start using stompman, make sure you have it installed:
15
15
  ```sh
16
16
  pip install stompman
17
17
  poetry add stompman
18
+ uv add stompman
18
19
  ```
19
20
 
20
21
  Initialize a client:
@@ -0,0 +1,20 @@
1
+ services:
2
+ app:
3
+ build:
4
+ context: .
5
+ args:
6
+ PYTHON_VERSION: ${PYTHON_VERSION:-3.12}
7
+ depends_on:
8
+ artemis:
9
+ condition: service_started
10
+ environment:
11
+ ARTEMIS_HOST: artemis
12
+
13
+ artemis:
14
+ image: apache/activemq-artemis:2.34.0-alpine
15
+ environment:
16
+ ARTEMIS_USER: admin
17
+ ARTEMIS_PASSWORD: admin
18
+ ports:
19
+ - 8161:8161
20
+ - 61616:61616
@@ -1,11 +1,11 @@
1
- [tool.poetry]
1
+ [project]
2
2
  name = "stompman"
3
- version = "0.6.2"
4
3
  description = "Python STOMP client with pleasant API"
5
- license = "MIT"
6
- authors = ["Lev Vereshchagin <mail@vrslev.com>"]
4
+ authors = [{ name = "Lev Vereshchagin", email = "mail@vrslev.com" }]
5
+ dependencies = []
6
+ requires-python = ">=3.11"
7
7
  readme = "README.md"
8
- repository = "https://github.com/vrslev/stompman"
8
+ license = { text = "MIT" }
9
9
  keywords = ["stomp", "artemis", "activemq", "messaging", "jms"]
10
10
  classifiers = [
11
11
  "Development Status :: 4 - Beta",
@@ -14,22 +14,26 @@ classifiers = [
14
14
  "Topic :: System :: Networking",
15
15
  "Typing :: Typed",
16
16
  ]
17
+ dynamic = ["version"]
17
18
 
18
- [tool.poetry.dependencies]
19
- python = "^3.11"
20
-
19
+ [project.urls]
20
+ repository = "https://github.com/vrslev/stompman"
21
21
 
22
- [tool.poetry.group.dev.dependencies]
23
- mypy = "^1.10.0"
24
- ruff = "^0.4.8"
25
- pytest = "^8.2.2"
26
- pytest-cov = "^5.0.0"
27
- anyio = "^4.4.0"
22
+ [tool.uv]
23
+ dev-dependencies = [
24
+ "mypy~=1.10.0",
25
+ "ruff~=0.4.8",
26
+ "pytest~=8.2.2",
27
+ "pytest-cov~=5.0.0",
28
+ "anyio~=4.4.0",
29
+ ]
28
30
 
29
31
  [build-system]
30
- requires = ["poetry-core"]
31
- build-backend = "poetry.core.masonry.api"
32
+ requires = ["hatchling", "hatch-vcs"]
33
+ build-backend = "hatchling.build"
32
34
 
35
+ [tool.hatch.version]
36
+ source = "vcs"
33
37
 
34
38
  [tool.mypy]
35
39
  python_version = "3.11"
@@ -83,6 +83,14 @@ class AbstractConnection(Protocol):
83
83
  return frame
84
84
 
85
85
 
86
+ @contextmanager
87
+ def _reraise_connection_lost(*causes: type[Exception]) -> Generator[None, None, None]:
88
+ try:
89
+ yield
90
+ except causes as exception:
91
+ raise ConnectionLostError from exception
92
+
93
+
86
94
  @dataclass
87
95
  class Connection(AbstractConnection):
88
96
  connection_parameters: ConnectionParameters
@@ -102,16 +110,9 @@ class Connection(AbstractConnection):
102
110
  return False
103
111
  return True
104
112
 
105
- @contextmanager
106
- def _reraise_connection_lost(self, *causes: type[Exception]) -> Generator[None, None, None]:
107
- try:
108
- yield
109
- except causes as exception:
110
- raise ConnectionLostError(self.read_timeout) from exception
111
-
112
113
  async def close(self) -> None:
113
114
  self.writer.close()
114
- with self._reraise_connection_lost(ConnectionError):
115
+ with _reraise_connection_lost(ConnectionError):
115
116
  await self.writer.wait_closed()
116
117
 
117
118
  def write_heartbeat(self) -> None:
@@ -119,7 +120,7 @@ class Connection(AbstractConnection):
119
120
 
120
121
  async def write_frame(self, frame: AnyClientFrame) -> None:
121
122
  self.writer.write(dump_frame(frame))
122
- with self._reraise_connection_lost(ConnectionError):
123
+ with _reraise_connection_lost(ConnectionError):
123
124
  await self.writer.drain()
124
125
 
125
126
  async def _read_non_empty_bytes(self) -> bytes:
@@ -133,7 +134,7 @@ class Connection(AbstractConnection):
133
134
  parser = Parser()
134
135
 
135
136
  while True:
136
- with self._reraise_connection_lost(ConnectionError, TimeoutError):
137
+ with _reraise_connection_lost(ConnectionError, TimeoutError):
137
138
  raw_frames = await asyncio.wait_for(self._read_non_empty_bytes(), timeout=self.read_timeout)
138
139
 
139
140
  for frame in cast(Iterator[AnyServerFrame], parser.load_frames(raw_frames)):
@@ -31,5 +31,4 @@ class FailedAllConnectAttemptsError(Error):
31
31
 
32
32
 
33
33
  @dataclass
34
- class ConnectionLostError(Error):
35
- timeout: int
34
+ class ConnectionLostError(Error): ...
File without changes
@@ -0,0 +1,19 @@
1
+ import asyncio
2
+
3
+ import stompman
4
+
5
+
6
+ async def main() -> None:
7
+ async with (
8
+ stompman.Client(servers=[stompman.ConnectionParameters("0.0.0.0", 61616, "admin", "admin")]) as client, # noqa: S104
9
+ client.subscribe("DLQ"),
10
+ ):
11
+ async for event in client.listen():
12
+ print(event) # noqa: T201
13
+ match event:
14
+ case stompman.MessageEvent():
15
+ await event.ack()
16
+
17
+
18
+ if __name__ == "__main__":
19
+ asyncio.run(main())
@@ -0,0 +1,18 @@
1
+ import asyncio
2
+
3
+ import stompman
4
+
5
+
6
+ async def main() -> None:
7
+ async with (
8
+ stompman.Client(servers=[stompman.ConnectionParameters("0.0.0.0", 61616, "admin", "admin")]) as client, # noqa: S104
9
+ client.enter_transaction() as transaction,
10
+ ):
11
+ for _ in range(10):
12
+ await client.send(body=b"hi there!", destination="DLQ", transaction=transaction)
13
+ await asyncio.sleep(3)
14
+ await client.send(body=b"hi there!", destination="DLQ", transaction=transaction)
15
+
16
+
17
+ if __name__ == "__main__":
18
+ asyncio.run(main())
File without changes
@@ -0,0 +1,6 @@
1
+ import pytest
2
+
3
+
4
+ @pytest.fixture(scope="session", autouse=True)
5
+ def anyio_backend() -> str:
6
+ return "asyncio"
@@ -0,0 +1,40 @@
1
+ import asyncio
2
+ import os
3
+ from uuid import uuid4
4
+
5
+ import stompman
6
+
7
+
8
+ async def test_integration() -> None:
9
+ server = stompman.ConnectionParameters(host=os.environ["ARTEMIS_HOST"], port=61616, login="admin", passcode="admin")
10
+ destination = "DLQ"
11
+ messages = [str(uuid4()).encode() for _ in range(10000)]
12
+
13
+ async def produce() -> None:
14
+ async with producer.enter_transaction() as transaction:
15
+ for message in messages:
16
+ await producer.send(
17
+ body=message, destination=destination, transaction=transaction, headers={"hello": "world"}
18
+ )
19
+
20
+ async def consume() -> None:
21
+ received_messages = []
22
+
23
+ async with asyncio.timeout(5), consumer.subscribe(destination=destination):
24
+ async for event in consumer.listen():
25
+ match event:
26
+ case stompman.MessageEvent(body=body):
27
+ await event.ack()
28
+ received_messages.append(body)
29
+ if len(received_messages) == len(messages):
30
+ break
31
+
32
+ assert sorted(received_messages) == sorted(messages)
33
+
34
+ async with (
35
+ stompman.Client(servers=[server], read_timeout=10, connection_confirmation_timeout=10) as consumer,
36
+ stompman.Client(servers=[server], read_timeout=10, connection_confirmation_timeout=10) as producer,
37
+ asyncio.TaskGroup() as task_group,
38
+ ):
39
+ task_group.create_task(consume())
40
+ task_group.create_task(produce())