macss-modular-api-rest-client 0.7.1__tar.gz → 0.7.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.
- {macss_modular_api_rest_client-0.7.1 → macss_modular_api_rest_client-0.7.3}/PKG-INFO +11 -5
- {macss_modular_api_rest_client-0.7.1 → macss_modular_api_rest_client-0.7.3}/README.md +6 -0
- {macss_modular_api_rest_client-0.7.1 → macss_modular_api_rest_client-0.7.3}/pyproject.toml +5 -5
- {macss_modular_api_rest_client-0.7.1 → macss_modular_api_rest_client-0.7.3}/src/macss_modular_api_rest_client.egg-info/PKG-INFO +11 -5
- {macss_modular_api_rest_client-0.7.1 → macss_modular_api_rest_client-0.7.3}/src/modular_api_rest_client/client.py +3 -3
- {macss_modular_api_rest_client-0.7.1 → macss_modular_api_rest_client-0.7.3}/tests/test_tracing.py +24 -24
- {macss_modular_api_rest_client-0.7.1 → macss_modular_api_rest_client-0.7.3}/setup.cfg +0 -0
- {macss_modular_api_rest_client-0.7.1 → macss_modular_api_rest_client-0.7.3}/src/macss_modular_api_rest_client.egg-info/SOURCES.txt +0 -0
- {macss_modular_api_rest_client-0.7.1 → macss_modular_api_rest_client-0.7.3}/src/macss_modular_api_rest_client.egg-info/dependency_links.txt +0 -0
- {macss_modular_api_rest_client-0.7.1 → macss_modular_api_rest_client-0.7.3}/src/macss_modular_api_rest_client.egg-info/requires.txt +0 -0
- {macss_modular_api_rest_client-0.7.1 → macss_modular_api_rest_client-0.7.3}/src/macss_modular_api_rest_client.egg-info/top_level.txt +0 -0
- {macss_modular_api_rest_client-0.7.1 → macss_modular_api_rest_client-0.7.3}/src/modular_api_rest_client/__init__.py +0 -0
- {macss_modular_api_rest_client-0.7.1 → macss_modular_api_rest_client-0.7.3}/src/modular_api_rest_client/client_tracing.py +0 -0
- {macss_modular_api_rest_client-0.7.1 → macss_modular_api_rest_client-0.7.3}/src/modular_api_rest_client/py.typed +0 -0
- {macss_modular_api_rest_client-0.7.1 → macss_modular_api_rest_client-0.7.3}/tests/test_dependency_boundary.py +0 -0
- {macss_modular_api_rest_client-0.7.1 → macss_modular_api_rest_client-0.7.3}/tests/test_http_client.py +0 -0
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: macss-modular-api-rest-client
|
|
3
|
-
Version: 0.7.
|
|
3
|
+
Version: 0.7.3
|
|
4
4
|
Summary: Official MACSS outbound REST client for Python.
|
|
5
5
|
Author: ccisne.dev
|
|
6
6
|
License-Expression: MIT
|
|
7
|
-
Project-URL: Homepage, https://github.com/
|
|
8
|
-
Project-URL: Repository, https://github.com/
|
|
9
|
-
Project-URL: Issues, https://github.com/
|
|
10
|
-
Project-URL: Documentation, https://github.com/
|
|
7
|
+
Project-URL: Homepage, https://github.com/ccisnedev/modular_api
|
|
8
|
+
Project-URL: Repository, https://github.com/ccisnedev/modular_api/tree/main/code/modular_api_rest_client/py
|
|
9
|
+
Project-URL: Issues, https://github.com/ccisnedev/modular_api/issues
|
|
10
|
+
Project-URL: Documentation, https://github.com/ccisnedev/modular_api/tree/main/code/modular_api_rest_client/py#readme
|
|
11
11
|
Keywords: macss,http,rest,client
|
|
12
12
|
Classifier: Development Status :: 4 - Beta
|
|
13
13
|
Classifier: Intended Audience :: Developers
|
|
@@ -29,6 +29,12 @@ Requires-Dist: pytest>=8.0; extra == "dev"
|
|
|
29
29
|
|
|
30
30
|
Official MACSS outbound REST client for Python.
|
|
31
31
|
|
|
32
|
+
## Install
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
pip install macss-modular-api-rest-client
|
|
36
|
+
```
|
|
37
|
+
|
|
32
38
|
## Quick start
|
|
33
39
|
|
|
34
40
|
```python
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "macss-modular-api-rest-client"
|
|
7
|
-
version = "0.7.
|
|
7
|
+
version = "0.7.3"
|
|
8
8
|
description = "Official MACSS outbound REST client for Python."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
license = "MIT"
|
|
@@ -43,10 +43,10 @@ dev = [
|
|
|
43
43
|
]
|
|
44
44
|
|
|
45
45
|
[project.urls]
|
|
46
|
-
Homepage = "https://github.com/
|
|
47
|
-
Repository = "https://github.com/
|
|
48
|
-
Issues = "https://github.com/
|
|
49
|
-
Documentation = "https://github.com/
|
|
46
|
+
Homepage = "https://github.com/ccisnedev/modular_api"
|
|
47
|
+
Repository = "https://github.com/ccisnedev/modular_api/tree/main/code/modular_api_rest_client/py"
|
|
48
|
+
Issues = "https://github.com/ccisnedev/modular_api/issues"
|
|
49
|
+
Documentation = "https://github.com/ccisnedev/modular_api/tree/main/code/modular_api_rest_client/py#readme"
|
|
50
50
|
|
|
51
51
|
[tool.setuptools.packages.find]
|
|
52
52
|
where = ["src"]
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: macss-modular-api-rest-client
|
|
3
|
-
Version: 0.7.
|
|
3
|
+
Version: 0.7.3
|
|
4
4
|
Summary: Official MACSS outbound REST client for Python.
|
|
5
5
|
Author: ccisne.dev
|
|
6
6
|
License-Expression: MIT
|
|
7
|
-
Project-URL: Homepage, https://github.com/
|
|
8
|
-
Project-URL: Repository, https://github.com/
|
|
9
|
-
Project-URL: Issues, https://github.com/
|
|
10
|
-
Project-URL: Documentation, https://github.com/
|
|
7
|
+
Project-URL: Homepage, https://github.com/ccisnedev/modular_api
|
|
8
|
+
Project-URL: Repository, https://github.com/ccisnedev/modular_api/tree/main/code/modular_api_rest_client/py
|
|
9
|
+
Project-URL: Issues, https://github.com/ccisnedev/modular_api/issues
|
|
10
|
+
Project-URL: Documentation, https://github.com/ccisnedev/modular_api/tree/main/code/modular_api_rest_client/py#readme
|
|
11
11
|
Keywords: macss,http,rest,client
|
|
12
12
|
Classifier: Development Status :: 4 - Beta
|
|
13
13
|
Classifier: Intended Audience :: Developers
|
|
@@ -29,6 +29,12 @@ Requires-Dist: pytest>=8.0; extra == "dev"
|
|
|
29
29
|
|
|
30
30
|
Official MACSS outbound REST client for Python.
|
|
31
31
|
|
|
32
|
+
## Install
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
pip install macss-modular-api-rest-client
|
|
36
|
+
```
|
|
37
|
+
|
|
32
38
|
## Quick start
|
|
33
39
|
|
|
34
40
|
```python
|
|
@@ -277,7 +277,7 @@ class HttpServiceClient:
|
|
|
277
277
|
)
|
|
278
278
|
except urllib.error.URLError as error:
|
|
279
279
|
# No response at all: a timeout, a refused connection, a DNS failure. The case
|
|
280
|
-
# that matters most for the
|
|
280
|
+
# that matters most for the production latency bursts, and unambiguously an error.
|
|
281
281
|
if tracing is not None:
|
|
282
282
|
tracing.complete(error=error)
|
|
283
283
|
reason = error.reason
|
|
@@ -305,7 +305,7 @@ class HttpServiceClient:
|
|
|
305
305
|
)
|
|
306
306
|
except (TimeoutError, socket.timeout) as error:
|
|
307
307
|
# No response at all: a timeout, a refused connection, a DNS failure. The case
|
|
308
|
-
# that matters most for the
|
|
308
|
+
# that matters most for the production latency bursts, and unambiguously an error.
|
|
309
309
|
if tracing is not None:
|
|
310
310
|
tracing.complete(error=error)
|
|
311
311
|
result = ServiceResult[ServiceResponse[T]].from_failure(
|
|
@@ -320,7 +320,7 @@ class HttpServiceClient:
|
|
|
320
320
|
)
|
|
321
321
|
except Exception as error: # noqa: BLE001
|
|
322
322
|
# No response at all: a timeout, a refused connection, a DNS failure. The case
|
|
323
|
-
# that matters most for the
|
|
323
|
+
# that matters most for the production latency bursts, and unambiguously an error.
|
|
324
324
|
if tracing is not None:
|
|
325
325
|
tracing.complete(error=error)
|
|
326
326
|
result = ServiceResult[ServiceResponse[T]].from_failure(
|
{macss_modular_api_rest_client-0.7.1 → macss_modular_api_rest_client-0.7.3}/tests/test_tracing.py
RENAMED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
"""Python mirror of ``test/tracing_test.dart``.
|
|
2
2
|
|
|
3
|
-
**This is the stage that satisfies G7
|
|
4
|
-
``POST /api/cuenta/get-
|
|
5
|
-
proxy to an upstream ``
|
|
3
|
+
**This is the stage that satisfies G7.** Its
|
|
4
|
+
``POST /api/cuenta/get-account-detail`` performs no database work at all — it is an HTTP
|
|
5
|
+
proxy to an upstream ``payments`` service (runbook D17) — so the client span is what shows
|
|
6
6
|
whether those 8–20 second bursts are spent in the outbound call or before it.
|
|
7
7
|
|
|
8
8
|
The propagator is set here, in the test, standing in for whatever the host configures
|
|
@@ -138,9 +138,9 @@ def _client(
|
|
|
138
138
|
) -> HttpServiceClient:
|
|
139
139
|
client = HttpServiceClient(
|
|
140
140
|
ServiceClientConfig(
|
|
141
|
-
service_id="
|
|
142
|
-
base_url="https://
|
|
143
|
-
redacted_summary="
|
|
141
|
+
service_id="payments",
|
|
142
|
+
base_url="https://payments.example/api",
|
|
143
|
+
redacted_summary="payments.example",
|
|
144
144
|
default_headers=default_headers or {},
|
|
145
145
|
)
|
|
146
146
|
)
|
|
@@ -151,7 +151,7 @@ def _client(
|
|
|
151
151
|
return client
|
|
152
152
|
|
|
153
153
|
|
|
154
|
-
def _call(client: HttpServiceClient, operation_id: str = "get-
|
|
154
|
+
def _call(client: HttpServiceClient, operation_id: str = "get-account-detail"): # noqa: ANN201
|
|
155
155
|
return client.execute(
|
|
156
156
|
ServiceRequest(
|
|
157
157
|
operation_id=operation_id,
|
|
@@ -165,7 +165,7 @@ def _call(client: HttpServiceClient, operation_id: str = "get-cuenta-detalle"):
|
|
|
165
165
|
|
|
166
166
|
def _within_server_span(body) -> None: # noqa: ANN001
|
|
167
167
|
server_span = _tracer.start_span(
|
|
168
|
-
"POST /api/cuenta/get-
|
|
168
|
+
"POST /api/cuenta/get-account-detail", kind=SpanKind.SERVER
|
|
169
169
|
)
|
|
170
170
|
with trace.use_span(server_span, end_on_exit=True):
|
|
171
171
|
body()
|
|
@@ -177,14 +177,14 @@ def _within_server_span(body) -> None: # noqa: ANN001
|
|
|
177
177
|
def test_emits_a_client_span_named_by_method_and_operation() -> None:
|
|
178
178
|
_within_server_span(lambda: _call(_client()))
|
|
179
179
|
|
|
180
|
-
assert _span_named("POST get-
|
|
180
|
+
assert _span_named("POST get-account-detail") is not None
|
|
181
181
|
|
|
182
182
|
|
|
183
183
|
def test_the_client_span_is_kind_client_and_a_child_of_the_server_span() -> None:
|
|
184
184
|
_within_server_span(lambda: _call(_client()))
|
|
185
185
|
|
|
186
|
-
server = _require_span("POST /api/cuenta/get-
|
|
187
|
-
client = _require_span("POST get-
|
|
186
|
+
server = _require_span("POST /api/cuenta/get-account-detail")
|
|
187
|
+
client = _require_span("POST get-account-detail")
|
|
188
188
|
|
|
189
189
|
assert client.kind is SpanKind.CLIENT
|
|
190
190
|
assert _context(client).trace_id == _context(server).trace_id
|
|
@@ -196,10 +196,10 @@ def test_records_the_upstream_host_and_path_not_the_full_url() -> None:
|
|
|
196
196
|
# what the conventions ask for and what is safe to store.
|
|
197
197
|
_within_server_span(lambda: _call(_client()))
|
|
198
198
|
|
|
199
|
-
attributes = _attributes(_require_span("POST get-
|
|
199
|
+
attributes = _attributes(_require_span("POST get-account-detail"))
|
|
200
200
|
|
|
201
|
-
assert attributes["server.address"] == "
|
|
202
|
-
assert "get-
|
|
201
|
+
assert attributes["server.address"] == "payments.example"
|
|
202
|
+
assert "get-account-detail" in str(attributes["url.path"])
|
|
203
203
|
assert attributes["http.request.method"] == "POST"
|
|
204
204
|
|
|
205
205
|
|
|
@@ -208,7 +208,7 @@ def test_injects_traceparent_derived_from_the_client_span() -> None:
|
|
|
208
208
|
# span, so a downstream hop attaches to the call rather than to its parent.
|
|
209
209
|
_within_server_span(lambda: _call(_client()))
|
|
210
210
|
|
|
211
|
-
client = _require_span("POST get-
|
|
211
|
+
client = _require_span("POST get-account-detail")
|
|
212
212
|
traceparent = _sent.get("traceparent")
|
|
213
213
|
|
|
214
214
|
assert traceparent is not None
|
|
@@ -218,11 +218,11 @@ def test_injects_traceparent_derived_from_the_client_span() -> None:
|
|
|
218
218
|
|
|
219
219
|
def test_a_500_from_upstream_sets_the_client_span_to_error() -> None:
|
|
220
220
|
error = urllib.error.HTTPError(
|
|
221
|
-
"https://
|
|
221
|
+
"https://payments.example/api", 500, "boom", Message(), io.BytesIO(b"")
|
|
222
222
|
)
|
|
223
223
|
_within_server_span(lambda: _call(_client(raises=error)))
|
|
224
224
|
|
|
225
|
-
client = _require_span("POST get-
|
|
225
|
+
client = _require_span("POST get-account-detail")
|
|
226
226
|
|
|
227
227
|
assert client.status.status_code is StatusCode.ERROR
|
|
228
228
|
assert _attributes(client)["http.response.status_code"] == 500
|
|
@@ -232,31 +232,31 @@ def test_a_404_from_upstream_also_sets_error_unlike_a_server_span() -> None:
|
|
|
232
232
|
# On a server span a 4xx is the caller's mistake. Here it means OUR outbound call failed,
|
|
233
233
|
# which is a different thing and worth distinguishing in a waterfall.
|
|
234
234
|
error = urllib.error.HTTPError(
|
|
235
|
-
"https://
|
|
235
|
+
"https://payments.example/api", 404, "missing", Message(), io.BytesIO(b"")
|
|
236
236
|
)
|
|
237
237
|
_within_server_span(lambda: _call(_client(raises=error)))
|
|
238
238
|
|
|
239
|
-
assert _require_span("POST get-
|
|
239
|
+
assert _require_span("POST get-account-detail").status.status_code is StatusCode.ERROR
|
|
240
240
|
|
|
241
241
|
|
|
242
242
|
def test_a_transport_failure_ends_the_span_with_error_and_no_status_code() -> None:
|
|
243
|
-
# The case that matters for the
|
|
243
|
+
# The case that matters for the production latency investigation: a call that never returns.
|
|
244
244
|
_within_server_span(
|
|
245
245
|
lambda: _call(_client(raises=urllib.error.URLError("connection reset")))
|
|
246
246
|
)
|
|
247
247
|
|
|
248
|
-
client = _require_span("POST get-
|
|
248
|
+
client = _require_span("POST get-account-detail")
|
|
249
249
|
|
|
250
250
|
assert client.status.status_code is StatusCode.ERROR
|
|
251
251
|
assert "http.response.status_code" not in _attributes(client)
|
|
252
252
|
|
|
253
253
|
|
|
254
254
|
def test_the_span_is_ended_which_is_the_g7_measurement() -> None:
|
|
255
|
-
# What the whole effort is for: separating "time spent calling
|
|
255
|
+
# What the whole effort is for: separating "time spent calling payments" from "time spent
|
|
256
256
|
# everywhere else". The number itself is production's to report.
|
|
257
257
|
_within_server_span(lambda: _call(_client()))
|
|
258
258
|
|
|
259
|
-
assert _require_span("POST get-
|
|
259
|
+
assert _require_span("POST get-account-detail").end_time is not None
|
|
260
260
|
|
|
261
261
|
|
|
262
262
|
# --- X-Request-ID forwarding (D23) ------------------------------------------
|
|
@@ -271,7 +271,7 @@ def test_an_inbound_request_id_is_forwarded_on_the_outbound_call() -> None:
|
|
|
271
271
|
|
|
272
272
|
|
|
273
273
|
def test_it_is_forwarded_even_with_tracing_off() -> None:
|
|
274
|
-
# The half of D23 that repairs D20:
|
|
274
|
+
# The half of D23 that repairs D20: payments does not run modular_api, so trace context
|
|
275
275
|
# dies there. If it logs the request id, log correlation still crosses the boundary — and
|
|
276
276
|
# that must not depend on tracing being enabled.
|
|
277
277
|
_call(_client(default_headers={REQUEST_ID_HEADER: "order-42"}))
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|