Repository navigation
feat: clientwright.contrib.servicewright behind a [servicewright] extra - #42
Merged
Merged
Conversation
servicewright's propagation_metadata already satisfies HeaderProvider bare; every service running both kits wrote the same AdapterDeps join by hand. servicewright_headers() returns (propagation_metadata,) as the providers tuple so it composes with AmbientDeadlineSource() instead of competing with it. The module imports servicewright at import time and raises the install hint the way contrib.dishka and contrib.settings do; the extra pins servicewright>=0.1,<1 the way [deadline] pins deadline-budget, and servicewright joins the "Core is stdlib-only" contract so the direction cannot drift. Closes #41
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #41
Problem
Every service running clientwright next to servicewright writes the same
AdapterDepsjoin by hand:header_providers=(servicewright.propagation_metadata,).propagation_metadataalready satisfiesHeaderProviderbare (__call__() -> Mapping[str, str], runtime-checkable; the function has had the same signature and root export since servicewright 0.1.0), so there is nothing to adapt — only a join to name, the waycontrib.deadlinenames the deadline-budget one.Design
clientwright.contrib.servicewrightbehind a[servicewright]extra, one function:AdapterDeps, so it composes with everything else injected there —AmbientDeadlineSource()included — instead of competing with it.clientwright[servicewright]install hint, the waycontrib.dishkaandcontrib.settingsdo. Unlikecontrib.deadlinethere is nothing structural to type; the real function is the point.servicewright>=0.1,<1, mirroring how[deadline]pins deadline-budget. servicewright isbump-minor-pre-majorand moves a minor almost weekly, so a single-minor cap would be a treadmill; the floor is honest because the export has not changed since 0.1.0.allgrows the same name.servicewrightadded to the "Core is stdlib-only" import-linter contract so the dependency direction cannot drift. servicewright has no dependency on clientwright, so the extra carries no cycle.Rejected: a ready-
AdapterDepsbuilder (propagation_deps(metrics=...)) — it becomes a second helper the moment one more field is needed, and it competes withcontrib.deadline. Also rejected: a documentation recipe only — no extra to pin the version and nothing to import, which is exactly the state every consumer is re-deriving.propagation_metadata'skeys=is not threaded through: nobody asked, and(partial(propagation_metadata, keys),)is the one-liner if someone does (documented on the guide page).Tests
(propagation_metadata,)and every element passesisinstance(..., HeaderProvider); the provider returns the bound ids insidebind_contextand{}outside.x-request-id/x-tenant-idfrom a realbind_contextand neither outside one.import clientwright.contrib.servicewrightwithout servicewright raises the install hint;servicewrightadded to the probe's blocked roots and to the guard-scan's SDK roots.make check).Docs
New guide page "Context propagation" next to "Deadline budgets" (nav updated), autodoc section on the contrib reference, install matrix row, README section,
docs/agents.md(install extras, contrib table, page map), a pointer from the observability wiring recipe.Verification
The reporter's
platform_rest_deps, with its body replaced byAdapterDeps(metrics=PrometheusClientMetrics(), header_providers=servicewright_headers(), deadline_source=AmbientDeadlineSource()), againstOriginServerwith a realbind_context(request_id, user_id, tenant_id, trace_id):Negative control: with
clientwright/contrib/servicewright.pyremoved, the four new tests fail on import; restored, they pass.