STATE-WP-0070: identity headers, archive 0069, phase-2 workplan
Add X-StateHub-Component to fix-consistency and other State Hub REST callers for legacy-meter attribution. Archive STATE-WP-0069; open STATE-WP-0070 for meter-gated phase-2 retirement. Task POST bodies use workplan_id only.
This commit is contained in:
parent
2f06751d4f
commit
bb6bec9f10
10 changed files with 198 additions and 17 deletions
|
|
@ -32,13 +32,15 @@ except Exception: # pragma: no cover — event publishing is optional
|
|||
publish_event = None # type: ignore[assignment]
|
||||
shutdown_publisher = None # type: ignore[assignment]
|
||||
|
||||
API = "http://127.0.0.1:8000"
|
||||
API = os.environ.get("API_BASE", "http://127.0.0.1:8000").rstrip("/")
|
||||
_LEGACY_METER_HEADERS = {"X-StateHub-Component": "state-hub.cleanup-stale-tasks"}
|
||||
STALE_STATUSES = set(OPEN_TASK_STATUSES)
|
||||
CLOSED_WS_STATUS = set(CLOSED_WORKSTREAM_STATUSES)
|
||||
|
||||
|
||||
def get(path: str) -> list | dict:
|
||||
with urllib.request.urlopen(f"{API}{path}") as r:
|
||||
req = urllib.request.Request(f"{API}{path}", headers=_LEGACY_METER_HEADERS)
|
||||
with urllib.request.urlopen(req) as r:
|
||||
return json.loads(r.read())
|
||||
|
||||
|
||||
|
|
@ -49,7 +51,7 @@ def _request(method: str, url: str, payload: dict) -> dict:
|
|||
req = urllib.request.Request(
|
||||
url,
|
||||
data=data,
|
||||
headers={"Content-Type": "application/json"},
|
||||
headers={"Content-Type": "application/json", **_LEGACY_METER_HEADERS},
|
||||
method=method,
|
||||
)
|
||||
try:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue