Skip to content

Commit 2fd7a3c

Browse files
committed
Added NNG broker.
1 parent 02700d4 commit 2fd7a3c

7 files changed

Lines changed: 268 additions & 128 deletions

File tree

.github/workflows/release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ jobs:
2121
- name: Setup python
2222
uses: actions/setup-python@v6
2323
with:
24-
python-version: '3.14'
24+
python-version: '3.14'
2525
- id: setup-uv
2626
name: Setup UV
2727
uses: astral-sh/setup-uv@v7

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ jobs:
5252
- name: Setup python
5353
uses: actions/setup-python@v6
5454
with:
55-
python-version: '${{ matrix.py_version }}'
55+
python-version: '${{ matrix.py_version }}'
5656
- id: setup-uv
5757
name: Setup UV
5858
uses: astral-sh/setup-uv@v7

docs/available-components/brokers.md

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,36 @@ pip install "taskiq[zmq]"
4343

4444
:::
4545

46+
## NNG broker
47+
48+
NNG broker is very much alike to the ZMQ broker. It is as lightweight as ZMQ, but uses NNG as an underlying socket
49+
management solution.
50+
51+
For more information visit their website at [nng.nanomsg.org](https://nng.nanomsg.org/).
52+
53+
::: caution Be careful!
54+
If you choose this type of broker, please run taskiq with `-w 1` parameter,
55+
otherwise you may encounter problems.
56+
:::
57+
58+
59+
::: tabs
60+
61+
@tab Only PyNNG
62+
63+
```bash
64+
pip install pynng
65+
```
66+
67+
@tab Taskiq with NNG
68+
69+
```bash
70+
pip install "taskiq[nng]"
71+
```
72+
73+
:::
74+
75+
4676
## Async shared broker and shared tasks
4777

4878
This is also a special broker. You cannot use it directly. It's used to create shared tasks.

docs/guide/message-format.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ After that, you can use your preferred serializer in your project like this:
114114

115115
```python
116116
from taskiq import InMemoryBroker
117-
from taskiq.serializers import ORJSONSerializer
117+
from taskiq.serializers import ORJSONSerializer
118118

119119
broker = InMemoryBroker().with_serializer(ORJSONSerializer())
120120
```
@@ -123,7 +123,7 @@ broker = InMemoryBroker().with_serializer(ORJSONSerializer())
123123

124124
```python
125125
from taskiq import InMemoryBroker
126-
from taskiq.serializers import MSGPackSerializer
126+
from taskiq.serializers import MSGPackSerializer
127127

128128
broker = InMemoryBroker().with_serializer(MSGPackSerializer())
129129
```
@@ -132,7 +132,7 @@ broker = InMemoryBroker().with_serializer(MSGPackSerializer())
132132

133133
```python
134134
from taskiq import InMemoryBroker
135-
from taskiq.serializers import CBORSerializer
135+
from taskiq.serializers import CBORSerializer
136136

137137
broker = InMemoryBroker().with_serializer(CBORSerializer())
138138
```

pyproject.toml

Lines changed: 123 additions & 122 deletions
Original file line numberDiff line numberDiff line change
@@ -2,84 +2,87 @@
22
name = "taskiq"
33
version = "0.0.0"
44
description = "Distributed task queue with full async support"
5-
authors = [{ name = "Pavel Kirilin", email = "<win10@list.ru>" }]
6-
maintainers = [{ name = "Pavel Kirilin", email = "<win10@list.ru>" }]
75
readme = "README.md"
8-
repository = "https://github.com/taskiq-python/taskiq"
9-
homepage = "https://taskiq-python.github.io/"
10-
documentation = "https://taskiq-python.github.io/"
6+
requires-python = ">=3.10,<4"
117
license = "MIT"
128
license-files = ["LICENSE"]
9+
authors = [{ name = "Pavel Kirilin", email = "<win10@list.ru>" }]
10+
maintainers = [{ name = "Pavel Kirilin", email = "<win10@list.ru>" }]
11+
keywords = ["async", "distributed", "taskiq", "tasks"]
1312
classifiers = [
14-
"Typing :: Typed",
15-
"Programming Language :: Python",
16-
"Programming Language :: Python :: 3",
17-
"Programming Language :: Python :: 3 :: Only",
18-
"Programming Language :: Python :: 3.10",
19-
"Programming Language :: Python :: 3.11",
20-
"Programming Language :: Python :: 3.12",
21-
"Programming Language :: Python :: 3.13",
22-
"Programming Language :: Python :: 3.14",
23-
"Operating System :: OS Independent",
24-
"Intended Audience :: Developers",
25-
"Topic :: System :: Networking",
26-
"Development Status :: 3 - Alpha",
27-
"License :: OSI Approved :: MIT License",
13+
"Development Status :: 3 - Alpha",
14+
"Intended Audience :: Developers",
15+
"License :: OSI Approved :: MIT License",
16+
"Operating System :: OS Independent",
17+
"Programming Language :: Python",
18+
"Programming Language :: Python :: 3",
19+
"Programming Language :: Python :: 3 :: Only",
20+
"Programming Language :: Python :: 3.10",
21+
"Programming Language :: Python :: 3.11",
22+
"Programming Language :: Python :: 3.12",
23+
"Programming Language :: Python :: 3.13",
24+
"Programming Language :: Python :: 3.14",
25+
"Topic :: System :: Networking",
26+
"Typing :: Typed",
2827
]
29-
keywords = ["taskiq", "tasks", "distributed", "async"]
30-
requires-python = ">=3.10,<4"
3128
dependencies = [
32-
"typing-extensions>=3.10.0.0; python_version < '3.11'",
33-
"pydantic>=1.0,<=3.0",
34-
"pycron>=3.0.0",
35-
"taskiq_dependencies>=1.3.1,<2",
36-
"anyio>=4",
37-
"packaging>=19",
38-
"aiohttp>=3",
29+
"aiohttp>=3",
30+
"anyio>=4",
31+
"packaging>=19",
32+
"pycron>=3.0.0",
33+
"pydantic>=1.0,<=3.0",
34+
"taskiq_dependencies>=1.3.1,<2",
35+
"typing-extensions>=3.10.0.0; python_version < '3.11'",
3936
]
37+
repository = "https://github.com/taskiq-python/taskiq"
38+
homepage = "https://taskiq-python.github.io/"
39+
documentation = "https://taskiq-python.github.io/"
4040

4141
[project.optional-dependencies]
42-
zmq = ["pyzmq>=26"]
43-
uv = ["uvloop>=0.16.0,<1; sys_platform != 'win32'"]
42+
cbor = ["cbor2>=5"]
4443
metrics = ["prometheus_client>=0"]
45-
reload = ["watchdog>=4", "gitignore-parser>=0"]
46-
orjson = ["orjson>=3"]
4744
msgpack = ["msgpack>=1.0.7"]
48-
cbor = ["cbor2>=5"]
45+
nng = [
46+
"pynng>=0.9.0,<1",
47+
]
4948
opentelemetry = [
50-
"opentelemetry-api (>=1.38.0,<2.0.0)",
51-
"opentelemetry-instrumentation (>=0.59b0,<1)",
52-
"opentelemetry-semantic-conventions (>=0.59b0,<1)",
49+
"opentelemetry-api (>=1.38.0,<2.0.0)",
50+
"opentelemetry-instrumentation (>=0.59b0,<1)",
51+
"opentelemetry-semantic-conventions (>=0.59b0,<1)",
5352
]
53+
orjson = ["orjson>=3"]
54+
reload = ["watchdog>=4", "gitignore-parser>=0"]
55+
uv = ["uvloop>=0.16.0,<1; sys_platform != 'win32'"]
56+
zmq = ["pyzmq>=26"]
5457

5558
[dependency-groups]
5659
dev = [
57-
"pre-commit>=4.4.0",
58-
# lint
59-
"ruff>=0.14.5",
60-
"black>=25.11.0",
61-
# type check
62-
"mypy>=1.18.2",
63-
# test
64-
"pytest>=9.0.1",
65-
"pytest-cov>=7.0.0",
66-
"coverage>=7.11.3",
67-
"pytest-xdist[psutil]>=3.8.0",
68-
"freezegun>=1.5.5",
69-
"tzdata>=2025.2; sys_platform == 'win32'",
70-
"opentelemetry-test-utils (>=0.59b0,<1)",
71-
"polyfactory>=3.1.0",
72-
# tests with all python versions
73-
"tox>=4.32.0",
74-
"tox-uv>=1.29.0",
60+
"black>=25.11.0",
61+
"coverage>=7.11.3",
62+
"freezegun>=1.5.5",
63+
# type check
64+
"mypy>=1.18.2",
65+
"opentelemetry-test-utils (>=0.59b0,<1)",
66+
"polyfactory>=3.1.0",
67+
"pre-commit>=4.4.0",
68+
# test
69+
"pytest>=9.0.1",
70+
"pytest-cov>=7.0.0",
71+
"pytest-xdist[psutil]>=3.8.0",
72+
# lint
73+
"ruff>=0.14.5",
74+
# tests with all python versions
75+
"tox>=4.32.0",
76+
"tox-uv>=1.29.0",
77+
"tzdata>=2025.2; sys_platform == 'win32'",
7578
]
7679

7780
[project.urls]
78-
Homepage = "https://taskiq-python.github.io/"
79-
Documentation = "https://taskiq-python.github.io/"
80-
Repository = "https://github.com/taskiq-python/taskiq"
8181
"Bug Tracker" = "https://github.com/taskiq-python/taskiq/issues"
8282
Changelog = "https://github.com/taskiq-python/taskiq/releases"
83+
Documentation = "https://taskiq-python.github.io/"
84+
Homepage = "https://taskiq-python.github.io/"
85+
Repository = "https://github.com/taskiq-python/taskiq"
8386

8487
[project.scripts]
8588
taskiq = "taskiq.__main__:main"
@@ -109,19 +112,19 @@ profile = "black"
109112
multi_line_output = 3
110113

111114
[tool.pytest.ini_options]
112-
log_level = 'INFO'
115+
log_level = "INFO"
113116
anyio_mode = "auto"
114117

115118
[tool.coverage.run]
116119
omit = [
117-
"taskiq/__main__.py",
118-
"taskiq/abc/cmd.py",
119-
"taskiq/cli/scheduler/args.py",
120-
"taskiq/cli/scheduler/cmd.py",
121-
"taskiq/cli/utils.py",
122-
"taskiq/cli/worker/args.py",
123-
"taskiq/cli/worker/async_task_runner.py",
124-
"taskiq/cli/worker/cmd.py",
120+
"taskiq/__main__.py",
121+
"taskiq/abc/cmd.py",
122+
"taskiq/cli/scheduler/args.py",
123+
"taskiq/cli/scheduler/cmd.py",
124+
"taskiq/cli/utils.py",
125+
"taskiq/cli/worker/args.py",
126+
"taskiq/cli/worker/async_task_runner.py",
127+
"taskiq/cli/worker/cmd.py",
125128
]
126129

127130
[build-system]
@@ -133,74 +136,74 @@ module-name = "taskiq"
133136
module-root = ""
134137

135138
[tool.ruff]
136-
target-version="py310"
139+
target-version = "py310"
137140
# List of enabled rulsets.
138141
# See https://docs.astral.sh/ruff/rules/ for more information.
139142
lint.select = [
140-
"E", # Error
141-
"F", # Pyflakes
142-
"W", # Pycodestyle
143-
"C90", # McCabe complexity
144-
"I", # Isort
145-
"N", # pep8-naming
146-
"D", # Pydocstyle
147-
"ANN", # Pytype annotations
148-
"S", # Bandit
149-
"B", # Bugbear
150-
"COM", # Commas
151-
"C4", # Comprehensions
152-
"ISC", # Implicit string concat
153-
"PIE", # Unnecessary code
154-
"T20", # Catch prints
155-
"PYI", # validate pyi files
156-
"Q", # Checks for quotes
157-
"RSE", # Checks raise statements
158-
"RET", # Checks return statements
159-
"SLF", # Self checks
160-
"SIM", # Simplificator
161-
"PTH", # Pathlib checks
162-
"ERA", # Checks for commented out code
163-
"PL", # PyLint checks
164-
"RUF", # Specific to Ruff checks
165-
"FA102", # Future annotations
166-
"UP", # Pyupgrade
143+
"E", # Error
144+
"F", # Pyflakes
145+
"W", # Pycodestyle
146+
"C90", # McCabe complexity
147+
"I", # Isort
148+
"N", # pep8-naming
149+
"D", # Pydocstyle
150+
"ANN", # Pytype annotations
151+
"S", # Bandit
152+
"B", # Bugbear
153+
"COM", # Commas
154+
"C4", # Comprehensions
155+
"ISC", # Implicit string concat
156+
"PIE", # Unnecessary code
157+
"T20", # Catch prints
158+
"PYI", # validate pyi files
159+
"Q", # Checks for quotes
160+
"RSE", # Checks raise statements
161+
"RET", # Checks return statements
162+
"SLF", # Self checks
163+
"SIM", # Simplificator
164+
"PTH", # Pathlib checks
165+
"ERA", # Checks for commented out code
166+
"PL", # PyLint checks
167+
"RUF", # Specific to Ruff checks
168+
"FA102", # Future annotations
169+
"UP", # Pyupgrade
167170
]
168171
lint.ignore = [
169-
"D105", # Missing docstring in magic method
170-
"D107", # Missing docstring in __init__
171-
"D212", # Multi-line docstring summary should start at the first line
172-
"D401", # First line should be in imperative mood
173-
"D104", # Missing docstring in public package
174-
"D100", # Missing docstring in public module
175-
"ANN401", # typing.Any are disallowed in `**kwargs
176-
"PLR0913", # Too many arguments for function call
177-
"D106", # Missing docstring in public nested class
172+
"D105", # Missing docstring in magic method
173+
"D107", # Missing docstring in __init__
174+
"D212", # Multi-line docstring summary should start at the first line
175+
"D401", # First line should be in imperative mood
176+
"D104", # Missing docstring in public package
177+
"D100", # Missing docstring in public module
178+
"ANN401", # typing.Any are disallowed in `**kwargs
179+
"PLR0913", # Too many arguments for function call
180+
"D106", # Missing docstring in public nested class
178181
]
179182
lint.mccabe = { max-complexity = 10 }
180183
exclude = [".venv/"]
181184
line-length = 88
182185

183186
[tool.ruff.lint.per-file-ignores]
184187
"taskiq/compat.py" = [
185-
"D103", # Missing docstring in public function
188+
"D103", # Missing docstring in public function
186189
]
187190
"tests/*" = [
188-
"S101", # Use of assert detected
189-
"S301", # Use of pickle detected
190-
"D103", # Missing docstring in public function
191-
"SLF001", # Private member accessed
192-
"S311", # Standard pseudo-random generators are not suitable for security/cryptographic purposes
193-
"D101", # Missing docstring in public class
194-
"D102", # Missing docstring in public method
195-
"PLR2004", # Magic value
191+
"S101", # Use of assert detected
192+
"S301", # Use of pickle detected
193+
"D103", # Missing docstring in public function
194+
"SLF001", # Private member accessed
195+
"S311", # Standard pseudo-random generators are not suitable for security/cryptographic purposes
196+
"D101", # Missing docstring in public class
197+
"D102", # Missing docstring in public method
198+
"PLR2004", # Magic value
196199
]
197200
"docs/examples/*" = [
198-
"D103", # Missing docstring in public function
199-
"D101", # Missing docstring in public class
200-
"D102", # Missing docstring in public method
201-
"S311", # Standard pseudo-random generators
202-
"S101", # use of asserts detected
203-
"T201", # print found
201+
"D103", # Missing docstring in public function
202+
"D101", # Missing docstring in public class
203+
"D102", # Missing docstring in public method
204+
"S311", # Standard pseudo-random generators
205+
"S101", # use of asserts detected
206+
"T201", # print found
204207
]
205208

206209
[tool.ruff.lint.pydocstyle]
@@ -215,7 +218,7 @@ extend-immutable-calls = ["taskiq_dependencies.Depends", "taskiq.TaskiqDepends"]
215218

216219
[tool.typos.files]
217220
extend-exclude = [
218-
"docs/README.md", # because of identifier in head section
221+
"docs/README.md", # because of identifier in head section
219222
]
220223

221224
[tool.tox]
@@ -227,6 +230,4 @@ env_list = ["3.13", "3.12", "3.11", "3.10"]
227230
description = "Run tests with Python {base_python}"
228231
runner = "uv-venv-lock-runner"
229232
uv_sync_flags = ["--all-extras"]
230-
commands = [
231-
["pytest", "-vv", "-n", "auto"]
232-
]
233+
commands = [["pytest", "-vv", "-n", "auto"]]

0 commit comments

Comments
 (0)