asbflow 1.0.0__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.
- asbflow-1.0.0/LICENSE +21 -0
- asbflow-1.0.0/PKG-INFO +164 -0
- asbflow-1.0.0/README.md +122 -0
- asbflow-1.0.0/pyproject.toml +69 -0
- asbflow-1.0.0/setup.cfg +4 -0
- asbflow-1.0.0/src/asbflow/__init__.py +75 -0
- asbflow-1.0.0/src/asbflow/auth/__init__.py +13 -0
- asbflow-1.0.0/src/asbflow/auth/base.py +50 -0
- asbflow-1.0.0/src/asbflow/auth/factory.py +42 -0
- asbflow-1.0.0/src/asbflow/auth/providers.py +126 -0
- asbflow-1.0.0/src/asbflow/config/__init__.py +40 -0
- asbflow-1.0.0/src/asbflow/config/connection.py +96 -0
- asbflow-1.0.0/src/asbflow/config/consumer.py +115 -0
- asbflow-1.0.0/src/asbflow/config/defaults.py +119 -0
- asbflow-1.0.0/src/asbflow/config/entity.py +28 -0
- asbflow-1.0.0/src/asbflow/config/publisher.py +91 -0
- asbflow-1.0.0/src/asbflow/consumer/__init__.py +29 -0
- asbflow-1.0.0/src/asbflow/consumer/base.py +160 -0
- asbflow-1.0.0/src/asbflow/consumer/factory.py +135 -0
- asbflow-1.0.0/src/asbflow/consumer/failure_handler.py +154 -0
- asbflow-1.0.0/src/asbflow/consumer/result.py +115 -0
- asbflow-1.0.0/src/asbflow/consumer/service.py +426 -0
- asbflow-1.0.0/src/asbflow/consumer/strategies/__init__.py +9 -0
- asbflow-1.0.0/src/asbflow/consumer/strategies/async_strategy.py +180 -0
- asbflow-1.0.0/src/asbflow/consumer/strategies/sequential.py +110 -0
- asbflow-1.0.0/src/asbflow/consumer/strategies/thread_pool.py +129 -0
- asbflow-1.0.0/src/asbflow/dlq/__init__.py +23 -0
- asbflow-1.0.0/src/asbflow/dlq/factory.py +101 -0
- asbflow-1.0.0/src/asbflow/dlq/protocols.py +44 -0
- asbflow-1.0.0/src/asbflow/dlq/result.py +132 -0
- asbflow-1.0.0/src/asbflow/dlq/service.py +314 -0
- asbflow-1.0.0/src/asbflow/entity/__init__.py +10 -0
- asbflow-1.0.0/src/asbflow/entity/base.py +38 -0
- asbflow-1.0.0/src/asbflow/entity/factory.py +32 -0
- asbflow-1.0.0/src/asbflow/entity/providers.py +54 -0
- asbflow-1.0.0/src/asbflow/exceptions.py +44 -0
- asbflow-1.0.0/src/asbflow/publisher/__init__.py +29 -0
- asbflow-1.0.0/src/asbflow/publisher/base.py +161 -0
- asbflow-1.0.0/src/asbflow/publisher/factory.py +146 -0
- asbflow-1.0.0/src/asbflow/publisher/service.py +309 -0
- asbflow-1.0.0/src/asbflow/publisher/strategies/__init__.py +9 -0
- asbflow-1.0.0/src/asbflow/publisher/strategies/async_strategy.py +116 -0
- asbflow-1.0.0/src/asbflow/publisher/strategies/sequential.py +57 -0
- asbflow-1.0.0/src/asbflow/publisher/strategies/thread_pool.py +73 -0
- asbflow-1.0.0/src/asbflow/py.typed +0 -0
- asbflow-1.0.0/src/asbflow/shared/__init__.py +45 -0
- asbflow-1.0.0/src/asbflow/shared/asb_ops.py +112 -0
- asbflow-1.0.0/src/asbflow/shared/message.py +17 -0
- asbflow-1.0.0/src/asbflow/shared/parsing.py +103 -0
- asbflow-1.0.0/src/asbflow/shared/payloads.py +80 -0
- asbflow-1.0.0/src/asbflow/shared/sdk.py +168 -0
- asbflow-1.0.0/src/asbflow.egg-info/PKG-INFO +164 -0
- asbflow-1.0.0/src/asbflow.egg-info/SOURCES.txt +54 -0
- asbflow-1.0.0/src/asbflow.egg-info/dependency_links.txt +1 -0
- asbflow-1.0.0/src/asbflow.egg-info/requires.txt +19 -0
- asbflow-1.0.0/src/asbflow.egg-info/top_level.txt +1 -0
asbflow-1.0.0/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Mattia Volpato
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
asbflow-1.0.0/PKG-INFO
ADDED
|
@@ -0,0 +1,164 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: asbflow
|
|
3
|
+
Version: 1.0.0
|
|
4
|
+
Summary: A high-level Azure Service Bus abstraction for publishing, consuming, and DLQ workflows.
|
|
5
|
+
Author-email: Mattia Volpato <volpato.mattia.2001@gmail.com>
|
|
6
|
+
License-Expression: MIT
|
|
7
|
+
Project-URL: Homepage, https://github.com/iFoxz17/asbflow
|
|
8
|
+
Project-URL: Repository, https://github.com/iFoxz17/asbflow
|
|
9
|
+
Project-URL: Issues, https://github.com/iFoxz17/asbflow/issues
|
|
10
|
+
Project-URL: Changelog, https://github.com/iFoxz17/asbflow/blob/main/CHANGELOG.md
|
|
11
|
+
Keywords: azure,service-bus,asb,messaging,dlq,pydantic
|
|
12
|
+
Classifier: Development Status :: 4 - Beta
|
|
13
|
+
Classifier: Intended Audience :: Developers
|
|
14
|
+
Classifier: Operating System :: OS Independent
|
|
15
|
+
Classifier: Programming Language :: Python :: 3
|
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
19
|
+
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
20
|
+
Classifier: Topic :: System :: Distributed Computing
|
|
21
|
+
Requires-Python: >=3.10
|
|
22
|
+
Description-Content-Type: text/markdown
|
|
23
|
+
License-File: LICENSE
|
|
24
|
+
Requires-Dist: azure-servicebus>=7.12.0
|
|
25
|
+
Requires-Dist: azure-identity>=1.16.0
|
|
26
|
+
Requires-Dist: pydantic>=2.0
|
|
27
|
+
Requires-Dist: overrides>=7.7.0
|
|
28
|
+
Provides-Extra: dev
|
|
29
|
+
Requires-Dist: pytest>=7.0; extra == "dev"
|
|
30
|
+
Requires-Dist: pytest-mock; extra == "dev"
|
|
31
|
+
Requires-Dist: black; extra == "dev"
|
|
32
|
+
Requires-Dist: isort; extra == "dev"
|
|
33
|
+
Requires-Dist: mypy; extra == "dev"
|
|
34
|
+
Requires-Dist: build>=1.2.2; extra == "dev"
|
|
35
|
+
Requires-Dist: twine>=5.1.1; extra == "dev"
|
|
36
|
+
Requires-Dist: pre-commit; extra == "dev"
|
|
37
|
+
Provides-Extra: notebook
|
|
38
|
+
Requires-Dist: jupyterlab>=4.2.0; extra == "notebook"
|
|
39
|
+
Requires-Dist: ipykernel>=6.29.0; extra == "notebook"
|
|
40
|
+
Requires-Dist: python-dotenv>=1.0.0; extra == "notebook"
|
|
41
|
+
Dynamic: license-file
|
|
42
|
+
|
|
43
|
+
# asbflow
|
|
44
|
+
|
|
45
|
+
`asbflow` is a Python library built on top of the Microsoft Azure Service Bus SDK that abstracts the most common messaging workflows.
|
|
46
|
+
|
|
47
|
+
## Workflow Status
|
|
48
|
+
|
|
49
|
+
[](https://github.com/iFoxz17/asbflow/actions/workflows/dev.yml)
|
|
50
|
+
[](https://github.com/iFoxz17/asbflow/actions/workflows/main.yml)
|
|
51
|
+
[](https://github.com/iFoxz17/asbflow/actions/workflows/release.yml)
|
|
52
|
+
|
|
53
|
+
It provides a clean service API for:
|
|
54
|
+
- publishing to topics and queues,
|
|
55
|
+
- consuming from subscriptions and queues,
|
|
56
|
+
- managing dead-letter queue (DLQ) operations.
|
|
57
|
+
|
|
58
|
+
The library is model-agnostic by default and integrates with Pydantic parsing when you want typed payload validation.
|
|
59
|
+
|
|
60
|
+
## Why asbflow
|
|
61
|
+
|
|
62
|
+
- Keep Azure Service Bus integration explicit but compact.
|
|
63
|
+
- Reuse the same high-level APIs across projects.
|
|
64
|
+
- Control parse behavior and settlement behavior per call.
|
|
65
|
+
- Use strategy-based execution (`sequential`, `thread_pool`, `async`) without changing business code.
|
|
66
|
+
|
|
67
|
+
## Core Components
|
|
68
|
+
|
|
69
|
+
- `ASBPublisher`: publish payloads (`dict` or Pydantic models).
|
|
70
|
+
- `ASBConsumer`: consume (settling) or read (non-settling) messages.
|
|
71
|
+
- `ASBDLQManager`: read/consume/redrive/purge DLQ messages.
|
|
72
|
+
- `ASBClientProvider`: pluggable auth provider (connection string or managed identity).
|
|
73
|
+
- Entity abstraction: topic/queue sender and receiver access via dedicated entity clients.
|
|
74
|
+
|
|
75
|
+
## Installation
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
pip install asbflow
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
For local development:
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
pip install -e .[dev]
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
For notebook quickstarts:
|
|
88
|
+
|
|
89
|
+
```bash
|
|
90
|
+
pip install -e .[notebook]
|
|
91
|
+
```
|
|
92
|
+
|
|
93
|
+
## Quick Start
|
|
94
|
+
|
|
95
|
+
```python
|
|
96
|
+
from asbflow import (
|
|
97
|
+
ASBConnectionConfig,
|
|
98
|
+
ASBConsumer,
|
|
99
|
+
ASBConsumerConfig,
|
|
100
|
+
ASBPublisher,
|
|
101
|
+
ASBPublisherConfig,
|
|
102
|
+
)
|
|
103
|
+
|
|
104
|
+
connection = ASBConnectionConfig(
|
|
105
|
+
connection_string="<connection-string>",
|
|
106
|
+
)
|
|
107
|
+
|
|
108
|
+
publisher = ASBPublisher(
|
|
109
|
+
connection=connection,
|
|
110
|
+
publisher=ASBPublisherConfig(topic_name="<topic-name>"),
|
|
111
|
+
)
|
|
112
|
+
|
|
113
|
+
consumer = ASBConsumer(
|
|
114
|
+
connection=connection,
|
|
115
|
+
consumer=ASBConsumerConfig(
|
|
116
|
+
topic_name="<topic-name>",
|
|
117
|
+
subscription_name="<subscription-name>",
|
|
118
|
+
),
|
|
119
|
+
)
|
|
120
|
+
|
|
121
|
+
publisher.publish(payload={"id": "a1", "severity": "high"}, parse=False)
|
|
122
|
+
result = consumer.consume(parse=False, raise_on_error=False)
|
|
123
|
+
print(result.succeeded, result.failed)
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
A richer walkthrough is available in [`quickstart/`](quickstart/README.md), including [`quickstart/asbflow_quickstart.ipynb`](quickstart/asbflow_quickstart.ipynb).
|
|
127
|
+
|
|
128
|
+
## Design Principles
|
|
129
|
+
|
|
130
|
+
- Abstraction over boilerplate, not over behavior.
|
|
131
|
+
- Safe defaults with explicit overrides.
|
|
132
|
+
- Uniform result contracts (`succeeded`, `failed`, `successes`, `failures`).
|
|
133
|
+
- Structured logging across services and strategies.
|
|
134
|
+
|
|
135
|
+
## Development
|
|
136
|
+
|
|
137
|
+
Run tests:
|
|
138
|
+
|
|
139
|
+
```bash
|
|
140
|
+
pytest -q test/unit
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
Build package:
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
python -m build
|
|
147
|
+
```
|
|
148
|
+
|
|
149
|
+
## CI/CD Branch Model
|
|
150
|
+
|
|
151
|
+
The repository ships with branch-oriented GitHub Actions:
|
|
152
|
+
- `dev`: fast CI feedback (tests + quality checks).
|
|
153
|
+
- `main`: full CI matrix + package build verification.
|
|
154
|
+
- `release`: release validation and publish workflow.
|
|
155
|
+
|
|
156
|
+
## Roadmap
|
|
157
|
+
|
|
158
|
+
- More built-in payload parser adapters.
|
|
159
|
+
- Additional reliability patterns around retries/backoff.
|
|
160
|
+
- Optional observability integrations (metrics/tracing).
|
|
161
|
+
|
|
162
|
+
## License
|
|
163
|
+
|
|
164
|
+
MIT. See [LICENSE](LICENSE).
|
asbflow-1.0.0/README.md
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
# asbflow
|
|
2
|
+
|
|
3
|
+
`asbflow` is a Python library built on top of the Microsoft Azure Service Bus SDK that abstracts the most common messaging workflows.
|
|
4
|
+
|
|
5
|
+
## Workflow Status
|
|
6
|
+
|
|
7
|
+
[](https://github.com/iFoxz17/asbflow/actions/workflows/dev.yml)
|
|
8
|
+
[](https://github.com/iFoxz17/asbflow/actions/workflows/main.yml)
|
|
9
|
+
[](https://github.com/iFoxz17/asbflow/actions/workflows/release.yml)
|
|
10
|
+
|
|
11
|
+
It provides a clean service API for:
|
|
12
|
+
- publishing to topics and queues,
|
|
13
|
+
- consuming from subscriptions and queues,
|
|
14
|
+
- managing dead-letter queue (DLQ) operations.
|
|
15
|
+
|
|
16
|
+
The library is model-agnostic by default and integrates with Pydantic parsing when you want typed payload validation.
|
|
17
|
+
|
|
18
|
+
## Why asbflow
|
|
19
|
+
|
|
20
|
+
- Keep Azure Service Bus integration explicit but compact.
|
|
21
|
+
- Reuse the same high-level APIs across projects.
|
|
22
|
+
- Control parse behavior and settlement behavior per call.
|
|
23
|
+
- Use strategy-based execution (`sequential`, `thread_pool`, `async`) without changing business code.
|
|
24
|
+
|
|
25
|
+
## Core Components
|
|
26
|
+
|
|
27
|
+
- `ASBPublisher`: publish payloads (`dict` or Pydantic models).
|
|
28
|
+
- `ASBConsumer`: consume (settling) or read (non-settling) messages.
|
|
29
|
+
- `ASBDLQManager`: read/consume/redrive/purge DLQ messages.
|
|
30
|
+
- `ASBClientProvider`: pluggable auth provider (connection string or managed identity).
|
|
31
|
+
- Entity abstraction: topic/queue sender and receiver access via dedicated entity clients.
|
|
32
|
+
|
|
33
|
+
## Installation
|
|
34
|
+
|
|
35
|
+
```bash
|
|
36
|
+
pip install asbflow
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
For local development:
|
|
40
|
+
|
|
41
|
+
```bash
|
|
42
|
+
pip install -e .[dev]
|
|
43
|
+
```
|
|
44
|
+
|
|
45
|
+
For notebook quickstarts:
|
|
46
|
+
|
|
47
|
+
```bash
|
|
48
|
+
pip install -e .[notebook]
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Quick Start
|
|
52
|
+
|
|
53
|
+
```python
|
|
54
|
+
from asbflow import (
|
|
55
|
+
ASBConnectionConfig,
|
|
56
|
+
ASBConsumer,
|
|
57
|
+
ASBConsumerConfig,
|
|
58
|
+
ASBPublisher,
|
|
59
|
+
ASBPublisherConfig,
|
|
60
|
+
)
|
|
61
|
+
|
|
62
|
+
connection = ASBConnectionConfig(
|
|
63
|
+
connection_string="<connection-string>",
|
|
64
|
+
)
|
|
65
|
+
|
|
66
|
+
publisher = ASBPublisher(
|
|
67
|
+
connection=connection,
|
|
68
|
+
publisher=ASBPublisherConfig(topic_name="<topic-name>"),
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
consumer = ASBConsumer(
|
|
72
|
+
connection=connection,
|
|
73
|
+
consumer=ASBConsumerConfig(
|
|
74
|
+
topic_name="<topic-name>",
|
|
75
|
+
subscription_name="<subscription-name>",
|
|
76
|
+
),
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
publisher.publish(payload={"id": "a1", "severity": "high"}, parse=False)
|
|
80
|
+
result = consumer.consume(parse=False, raise_on_error=False)
|
|
81
|
+
print(result.succeeded, result.failed)
|
|
82
|
+
```
|
|
83
|
+
|
|
84
|
+
A richer walkthrough is available in [`quickstart/`](quickstart/README.md), including [`quickstart/asbflow_quickstart.ipynb`](quickstart/asbflow_quickstart.ipynb).
|
|
85
|
+
|
|
86
|
+
## Design Principles
|
|
87
|
+
|
|
88
|
+
- Abstraction over boilerplate, not over behavior.
|
|
89
|
+
- Safe defaults with explicit overrides.
|
|
90
|
+
- Uniform result contracts (`succeeded`, `failed`, `successes`, `failures`).
|
|
91
|
+
- Structured logging across services and strategies.
|
|
92
|
+
|
|
93
|
+
## Development
|
|
94
|
+
|
|
95
|
+
Run tests:
|
|
96
|
+
|
|
97
|
+
```bash
|
|
98
|
+
pytest -q test/unit
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
Build package:
|
|
102
|
+
|
|
103
|
+
```bash
|
|
104
|
+
python -m build
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
## CI/CD Branch Model
|
|
108
|
+
|
|
109
|
+
The repository ships with branch-oriented GitHub Actions:
|
|
110
|
+
- `dev`: fast CI feedback (tests + quality checks).
|
|
111
|
+
- `main`: full CI matrix + package build verification.
|
|
112
|
+
- `release`: release validation and publish workflow.
|
|
113
|
+
|
|
114
|
+
## Roadmap
|
|
115
|
+
|
|
116
|
+
- More built-in payload parser adapters.
|
|
117
|
+
- Additional reliability patterns around retries/backoff.
|
|
118
|
+
- Optional observability integrations (metrics/tracing).
|
|
119
|
+
|
|
120
|
+
## License
|
|
121
|
+
|
|
122
|
+
MIT. See [LICENSE](LICENSE).
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools>=61", "wheel"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "asbflow"
|
|
7
|
+
version = "1.0.0"
|
|
8
|
+
description = "A high-level Azure Service Bus abstraction for publishing, consuming, and DLQ workflows."
|
|
9
|
+
readme = "README.md"
|
|
10
|
+
license = "MIT"
|
|
11
|
+
authors = [{name = "Mattia Volpato", email = "volpato.mattia.2001@gmail.com"}]
|
|
12
|
+
requires-python = ">=3.10"
|
|
13
|
+
keywords = ["azure", "service-bus", "asb", "messaging", "dlq", "pydantic"]
|
|
14
|
+
classifiers = [
|
|
15
|
+
"Development Status :: 4 - Beta",
|
|
16
|
+
"Intended Audience :: Developers",
|
|
17
|
+
"Operating System :: OS Independent",
|
|
18
|
+
"Programming Language :: Python :: 3",
|
|
19
|
+
"Programming Language :: Python :: 3.10",
|
|
20
|
+
"Programming Language :: Python :: 3.11",
|
|
21
|
+
"Programming Language :: Python :: 3.12",
|
|
22
|
+
"Topic :: Software Development :: Libraries :: Python Modules",
|
|
23
|
+
"Topic :: System :: Distributed Computing",
|
|
24
|
+
]
|
|
25
|
+
|
|
26
|
+
dependencies = [
|
|
27
|
+
"azure-servicebus>=7.12.0",
|
|
28
|
+
"azure-identity>=1.16.0",
|
|
29
|
+
"pydantic>=2.0",
|
|
30
|
+
"overrides>=7.7.0"
|
|
31
|
+
]
|
|
32
|
+
|
|
33
|
+
[project.optional-dependencies]
|
|
34
|
+
dev = [
|
|
35
|
+
"pytest>=7.0",
|
|
36
|
+
"pytest-mock",
|
|
37
|
+
"black",
|
|
38
|
+
"isort",
|
|
39
|
+
"mypy",
|
|
40
|
+
"build>=1.2.2",
|
|
41
|
+
"twine>=5.1.1",
|
|
42
|
+
"pre-commit",
|
|
43
|
+
]
|
|
44
|
+
notebook = [
|
|
45
|
+
"jupyterlab>=4.2.0",
|
|
46
|
+
"ipykernel>=6.29.0",
|
|
47
|
+
"python-dotenv>=1.0.0",
|
|
48
|
+
]
|
|
49
|
+
|
|
50
|
+
[project.urls]
|
|
51
|
+
Homepage = "https://github.com/iFoxz17/asbflow"
|
|
52
|
+
Repository = "https://github.com/iFoxz17/asbflow"
|
|
53
|
+
Issues = "https://github.com/iFoxz17/asbflow/issues"
|
|
54
|
+
Changelog = "https://github.com/iFoxz17/asbflow/blob/main/CHANGELOG.md"
|
|
55
|
+
|
|
56
|
+
[tool.setuptools]
|
|
57
|
+
packages = {find = {where = ["src"]}}
|
|
58
|
+
|
|
59
|
+
[tool.setuptools.package-data]
|
|
60
|
+
"asbflow" = ["py.typed"]
|
|
61
|
+
|
|
62
|
+
[tool.black]
|
|
63
|
+
line-length = 120
|
|
64
|
+
target-version = ["py310"]
|
|
65
|
+
|
|
66
|
+
[tool.isort]
|
|
67
|
+
profile = "black"
|
|
68
|
+
line_length = 120
|
|
69
|
+
src_paths = ["src", "test", "quickstart"]
|
asbflow-1.0.0/setup.cfg
ADDED
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
from importlib.metadata import PackageNotFoundError, version
|
|
2
|
+
|
|
3
|
+
from asbflow.config import (
|
|
4
|
+
ASBAuthMethod,
|
|
5
|
+
ASBConnectionConfig,
|
|
6
|
+
ASBConsumerConfig,
|
|
7
|
+
ASBMessageConfig,
|
|
8
|
+
ASBMessagingEntity,
|
|
9
|
+
ASBPublisherConfig,
|
|
10
|
+
ParseFailurePolicy,
|
|
11
|
+
)
|
|
12
|
+
from asbflow.consumer import (
|
|
13
|
+
ASBConsumer,
|
|
14
|
+
ConsumedPayloadFailure,
|
|
15
|
+
ConsumeExecutionMode,
|
|
16
|
+
ConsumeResult,
|
|
17
|
+
ParsedConsumeResult,
|
|
18
|
+
PydanticModelParser,
|
|
19
|
+
RawConsumeResult,
|
|
20
|
+
create_consumer,
|
|
21
|
+
)
|
|
22
|
+
from asbflow.dlq import (
|
|
23
|
+
ASBDLQManager,
|
|
24
|
+
DLQParsedReadResult,
|
|
25
|
+
DLQPurgeResult,
|
|
26
|
+
DLQRawReadResult,
|
|
27
|
+
DLQReadResult,
|
|
28
|
+
DLQRedriveResult,
|
|
29
|
+
create_dlq_manager,
|
|
30
|
+
)
|
|
31
|
+
from asbflow.exceptions import (
|
|
32
|
+
ConsumeError,
|
|
33
|
+
DLQError,
|
|
34
|
+
DLQPublisherNotConfiguredError,
|
|
35
|
+
PublishError,
|
|
36
|
+
)
|
|
37
|
+
from asbflow.publisher import ASBPublisher, PublishExecutionMode, create_publisher
|
|
38
|
+
|
|
39
|
+
try:
|
|
40
|
+
__version__ = version("asbflow")
|
|
41
|
+
except PackageNotFoundError:
|
|
42
|
+
__version__ = "0.0.0"
|
|
43
|
+
|
|
44
|
+
__all__ = [
|
|
45
|
+
"__version__",
|
|
46
|
+
"ASBConnectionConfig",
|
|
47
|
+
"ASBPublisherConfig",
|
|
48
|
+
"ASBConsumerConfig",
|
|
49
|
+
"ASBMessagingEntity",
|
|
50
|
+
"ParseFailurePolicy",
|
|
51
|
+
"ASBAuthMethod",
|
|
52
|
+
"ASBMessageConfig",
|
|
53
|
+
"ASBPublisher",
|
|
54
|
+
"create_publisher",
|
|
55
|
+
"PublishExecutionMode",
|
|
56
|
+
"ASBConsumer",
|
|
57
|
+
"create_consumer",
|
|
58
|
+
"ASBDLQManager",
|
|
59
|
+
"create_dlq_manager",
|
|
60
|
+
"ConsumeExecutionMode",
|
|
61
|
+
"RawConsumeResult",
|
|
62
|
+
"ParsedConsumeResult",
|
|
63
|
+
"ConsumeResult",
|
|
64
|
+
"ConsumedPayloadFailure",
|
|
65
|
+
"DLQRawReadResult",
|
|
66
|
+
"DLQParsedReadResult",
|
|
67
|
+
"DLQReadResult",
|
|
68
|
+
"DLQRedriveResult",
|
|
69
|
+
"DLQPurgeResult",
|
|
70
|
+
"ConsumeError",
|
|
71
|
+
"PublishError",
|
|
72
|
+
"DLQError",
|
|
73
|
+
"DLQPublisherNotConfiguredError",
|
|
74
|
+
"PydanticModelParser",
|
|
75
|
+
]
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
from asbflow.auth.base import ASBClientProvider
|
|
2
|
+
from asbflow.auth.factory import ASBClientProviderFactory
|
|
3
|
+
from asbflow.auth.providers import (
|
|
4
|
+
ConnectionStringClientProvider,
|
|
5
|
+
ManagedIdentityClientProvider,
|
|
6
|
+
)
|
|
7
|
+
|
|
8
|
+
__all__ = [
|
|
9
|
+
"ASBClientProvider",
|
|
10
|
+
"ASBClientProviderFactory",
|
|
11
|
+
"ConnectionStringClientProvider",
|
|
12
|
+
"ManagedIdentityClientProvider",
|
|
13
|
+
]
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from abc import ABC, abstractmethod
|
|
4
|
+
|
|
5
|
+
from asbflow.config.connection import ASBConnectionConfig
|
|
6
|
+
from asbflow.shared.sdk import ASBAsyncClient, ASBSyncClient
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class ASBClientProvider(ABC):
|
|
10
|
+
"""Base abstraction for Azure Service Bus client providers."""
|
|
11
|
+
|
|
12
|
+
def __init__(self, config: ASBConnectionConfig) -> None:
|
|
13
|
+
"""Initialize the provider.
|
|
14
|
+
|
|
15
|
+
Parameters
|
|
16
|
+
----------
|
|
17
|
+
config : ASBConnectionConfig
|
|
18
|
+
Connection/auth configuration used to create clients.
|
|
19
|
+
"""
|
|
20
|
+
self._config: ASBConnectionConfig = config
|
|
21
|
+
|
|
22
|
+
@property
|
|
23
|
+
def config(self) -> ASBConnectionConfig:
|
|
24
|
+
"""Return the connection configuration used by this provider."""
|
|
25
|
+
return self._config
|
|
26
|
+
|
|
27
|
+
@abstractmethod
|
|
28
|
+
def create_sync_client(self) -> ASBSyncClient:
|
|
29
|
+
"""Create a synchronous Azure Service Bus client.
|
|
30
|
+
|
|
31
|
+
Returns
|
|
32
|
+
-------
|
|
33
|
+
ASBSyncClient
|
|
34
|
+
Sync client implementing context manager semantics.
|
|
35
|
+
"""
|
|
36
|
+
raise NotImplementedError
|
|
37
|
+
|
|
38
|
+
@abstractmethod
|
|
39
|
+
async def create_async_client(self) -> ASBAsyncClient:
|
|
40
|
+
"""Create an asynchronous Azure Service Bus client.
|
|
41
|
+
|
|
42
|
+
Returns
|
|
43
|
+
-------
|
|
44
|
+
ASBAsyncClient
|
|
45
|
+
Async client implementing async context manager semantics.
|
|
46
|
+
"""
|
|
47
|
+
raise NotImplementedError
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
__all__ = ["ASBClientProvider"]
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from asbflow.auth.base import ASBClientProvider
|
|
4
|
+
from asbflow.auth.providers import (
|
|
5
|
+
ConnectionStringClientProvider,
|
|
6
|
+
ManagedIdentityClientProvider,
|
|
7
|
+
)
|
|
8
|
+
from asbflow.config.connection import ASBAuthMethod, ASBConnectionConfig
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class ASBClientProviderFactory:
|
|
12
|
+
"""Build the client provider matching the configured auth method."""
|
|
13
|
+
|
|
14
|
+
@staticmethod
|
|
15
|
+
def create(config: ASBConnectionConfig) -> ASBClientProvider:
|
|
16
|
+
"""Create an auth provider.
|
|
17
|
+
|
|
18
|
+
Parameters
|
|
19
|
+
----------
|
|
20
|
+
config : ASBConnectionConfig
|
|
21
|
+
Connection/auth configuration.
|
|
22
|
+
|
|
23
|
+
Returns
|
|
24
|
+
-------
|
|
25
|
+
ASBClientProvider
|
|
26
|
+
Provider implementation compatible with the selected auth method.
|
|
27
|
+
|
|
28
|
+
Raises
|
|
29
|
+
------
|
|
30
|
+
ValueError
|
|
31
|
+
If the auth method is unsupported.
|
|
32
|
+
"""
|
|
33
|
+
match config.auth:
|
|
34
|
+
case ASBAuthMethod.CONNECTION_STRING:
|
|
35
|
+
return ConnectionStringClientProvider(config)
|
|
36
|
+
case ASBAuthMethod.MANAGED_IDENTITY:
|
|
37
|
+
return ManagedIdentityClientProvider(config)
|
|
38
|
+
|
|
39
|
+
raise ValueError(f"Unsupported Service Bus auth method: {config.auth}")
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
__all__ = ["ASBClientProviderFactory"]
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from importlib import import_module
|
|
4
|
+
from types import ModuleType
|
|
5
|
+
from typing import Any
|
|
6
|
+
|
|
7
|
+
from asbflow.auth.base import ASBClientProvider
|
|
8
|
+
from asbflow.config.connection import ASBConnectionConfig
|
|
9
|
+
from asbflow.config.defaults import get_asbflow_logger
|
|
10
|
+
from asbflow.shared.sdk import (
|
|
11
|
+
ASBAsyncClient,
|
|
12
|
+
ASBAsyncClientFactory,
|
|
13
|
+
ASBSyncClient,
|
|
14
|
+
ASBSyncClientFactory,
|
|
15
|
+
load_asb_async_client,
|
|
16
|
+
load_asb_client_factory,
|
|
17
|
+
)
|
|
18
|
+
|
|
19
|
+
LOGGER = get_asbflow_logger(__name__)
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class ConnectionStringClientProvider(ASBClientProvider):
|
|
23
|
+
"""Create clients using Service Bus connection-string authentication."""
|
|
24
|
+
|
|
25
|
+
def create_sync_client(self) -> ASBSyncClient:
|
|
26
|
+
"""Create a synchronous client from connection-string auth.
|
|
27
|
+
|
|
28
|
+
Returns
|
|
29
|
+
-------
|
|
30
|
+
ASBSyncClient
|
|
31
|
+
Synchronous Service Bus client.
|
|
32
|
+
"""
|
|
33
|
+
LOGGER.info("Creating synchronous ASB client with connection-string auth")
|
|
34
|
+
servicebus_client: ASBSyncClientFactory = load_asb_client_factory()
|
|
35
|
+
LOGGER.debug(
|
|
36
|
+
"Loaded sync ASB factory class: %s",
|
|
37
|
+
type(servicebus_client).__name__,
|
|
38
|
+
)
|
|
39
|
+
return servicebus_client.from_connection_string(**self.config.to_connection_string_client_kwargs())
|
|
40
|
+
|
|
41
|
+
async def create_async_client(self) -> ASBAsyncClient:
|
|
42
|
+
"""Create an asynchronous client from connection-string auth.
|
|
43
|
+
|
|
44
|
+
Returns
|
|
45
|
+
-------
|
|
46
|
+
ASBAsyncClient
|
|
47
|
+
Asynchronous Service Bus client.
|
|
48
|
+
"""
|
|
49
|
+
LOGGER.info("Creating asynchronous ASB client with connection-string auth")
|
|
50
|
+
servicebus_client: ASBAsyncClientFactory = load_asb_async_client()
|
|
51
|
+
LOGGER.debug(
|
|
52
|
+
"Loaded async ASB factory class: %s",
|
|
53
|
+
type(servicebus_client).__name__,
|
|
54
|
+
)
|
|
55
|
+
return servicebus_client.from_connection_string(**self.config.to_connection_string_client_kwargs())
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
class ManagedIdentityClientProvider(ASBClientProvider):
|
|
59
|
+
"""Create clients using Azure Managed Identity authentication."""
|
|
60
|
+
|
|
61
|
+
def _build_credential(self) -> Any:
|
|
62
|
+
config: ASBConnectionConfig = self.config
|
|
63
|
+
if config.credential is not None:
|
|
64
|
+
LOGGER.debug("Using explicit credential instance from configuration")
|
|
65
|
+
return self.config.credential
|
|
66
|
+
|
|
67
|
+
try:
|
|
68
|
+
identity_module: ModuleType = import_module("azure.identity")
|
|
69
|
+
except Exception:
|
|
70
|
+
LOGGER.exception("Unable to import azure.identity while building managed-identity credential")
|
|
71
|
+
raise
|
|
72
|
+
|
|
73
|
+
credential_class: Any = getattr(identity_module, "ManagedIdentityCredential")
|
|
74
|
+
if config.managed_identity_client_id is not None:
|
|
75
|
+
LOGGER.debug("Building ManagedIdentityCredential with client_id")
|
|
76
|
+
return credential_class(client_id=config.managed_identity_client_id)
|
|
77
|
+
|
|
78
|
+
LOGGER.debug("Building default ManagedIdentityCredential")
|
|
79
|
+
return credential_class()
|
|
80
|
+
|
|
81
|
+
def _build_kwargs(self) -> dict[str, Any]:
|
|
82
|
+
credential: Any = self._build_credential()
|
|
83
|
+
LOGGER.debug(
|
|
84
|
+
"Managed-identity client kwargs prepared (namespace=%s, logging_enable=%s)",
|
|
85
|
+
self.config.fully_qualified_namespace,
|
|
86
|
+
self.config.logging_enable,
|
|
87
|
+
)
|
|
88
|
+
return self.config.to_managed_identity_client_kwargs(credential=credential)
|
|
89
|
+
|
|
90
|
+
def create_sync_client(self) -> ASBSyncClient:
|
|
91
|
+
"""Create a synchronous client from managed-identity auth.
|
|
92
|
+
|
|
93
|
+
Returns
|
|
94
|
+
-------
|
|
95
|
+
ASBSyncClient
|
|
96
|
+
Synchronous Service Bus client.
|
|
97
|
+
"""
|
|
98
|
+
LOGGER.info("Creating synchronous ASB client with managed-identity auth")
|
|
99
|
+
servicebus_client: ASBSyncClientFactory = load_asb_client_factory()
|
|
100
|
+
LOGGER.debug(
|
|
101
|
+
"Loaded sync ASB factory class: %s",
|
|
102
|
+
type(servicebus_client).__name__,
|
|
103
|
+
)
|
|
104
|
+
return servicebus_client(**self._build_kwargs())
|
|
105
|
+
|
|
106
|
+
async def create_async_client(self) -> ASBAsyncClient:
|
|
107
|
+
"""Create an asynchronous client from managed-identity auth.
|
|
108
|
+
|
|
109
|
+
Returns
|
|
110
|
+
-------
|
|
111
|
+
ASBAsyncClient
|
|
112
|
+
Asynchronous Service Bus client.
|
|
113
|
+
"""
|
|
114
|
+
LOGGER.info("Creating asynchronous ASB client with managed-identity auth")
|
|
115
|
+
servicebus_client: ASBAsyncClientFactory = load_asb_async_client()
|
|
116
|
+
LOGGER.debug(
|
|
117
|
+
"Loaded async ASB factory class: %s",
|
|
118
|
+
type(servicebus_client).__name__,
|
|
119
|
+
)
|
|
120
|
+
return servicebus_client(**self._build_kwargs())
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
__all__ = [
|
|
124
|
+
"ConnectionStringClientProvider",
|
|
125
|
+
"ManagedIdentityClientProvider",
|
|
126
|
+
]
|