-
Notifications
You must be signed in to change notification settings - Fork 11
feat(client): carry request priority on RequestContext #1205
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: infrahub-develop
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1 @@ | ||
| The request priority (`X-Priority` header) can now be carried on the client's `RequestContext` via a new `priority` field, alongside the existing client-wide `Config.priority` default and per-call `priority=` override. Resolution precedence is per-call `priority=` > `request_context.priority` > `Config.priority` > no header. The priority is emitted as a header only and is never included in the mutation body. Works identically on `InfrahubClient` and `InfrahubClientSync`. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1 +1 @@ | ||
| Added support for tagging SDK requests with a priority via a new `X-Priority` header. A `Priority` enum (`high`, `normal`, `low`) is available from `infrahub_sdk.constants`; set `Config.priority` (env var `INFRAHUB_PRIORITY`) for a client-wide default emitted on every request, or pass `priority=` to individual operations to override it per request. When unset, no header is sent. Works identically on `InfrahubClient` and `InfrahubClientSync`. | ||
| Added support for tagging SDK requests with a priority via a new `X-Priority` header. A `Priority` enum (`high`, `medium`, `low`) is available from `infrahub_sdk.constants`; set `Config.priority` (env var `INFRAHUB_PRIORITY`) for a client-wide default emitted on every request, or pass `priority=` to individual operations to override it per request. When unset, no header is sent. Works identically on `InfrahubClient` and `InfrahubClientSync`. |
| Original file line number | Diff line number | Diff line change | ||||||
|---|---|---|---|---|---|---|---|---|
|
|
@@ -17,7 +17,7 @@ class Priority(str, enum.Enum): | |||||||
| """ | ||||||||
|
|
||||||||
| HIGH = "high" | ||||||||
| NORMAL = "normal" | ||||||||
| MEDIUM = "medium" | ||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: Existing SDK callers using Prompt for AI agents
Suggested change
|
||||||||
| LOW = "low" | ||||||||
|
|
||||||||
| @classmethod | ||||||||
|
|
||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -282,14 +282,15 @@ def __setattr__(self, name: str, value: Any) -> None: | |
| super().__setattr__(name, value) | ||
|
|
||
| def _get_request_context(self, request_context: RequestContext | None = None) -> dict[str, Any] | None: | ||
| # priority rides the X-Priority header, not the mutation body — the server context input has no such field | ||
| if request_context: | ||
| return request_context.model_dump(exclude_none=True) | ||
| return request_context.model_dump(exclude_none=True, exclude={"priority"}) or None | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. P2: A per-call Prompt for AI agents |
||
|
|
||
| client: InfrahubClient | InfrahubClientSync | None = getattr(self, "_client", None) | ||
| if not client or not client.request_context: | ||
| return None | ||
|
|
||
| return client.request_context.model_dump(exclude_none=True) | ||
| return client.request_context.model_dump(exclude_none=True, exclude={"priority"}) or None | ||
|
|
||
| def _init_relationships(self, data: dict | None = None) -> None: | ||
| pass | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
P2: File downloads, artifact-generation calls, and password-authentication requests still omit
RequestContext.prioritybecause they bypass_request_headers; the companion admission layer classifies a missing header as MEDIUM at opsmill/infrahub#9879/backend/infrahub/api/admission/middleware.py:87-92, so high/low work on these paths can be admitted or shed at the wrong tier. Centralizing the context-priority merge in the low-level transports would cover all request paths.Prompt for AI agents