feat: report capacity waits in function refresh job status (#5154)

An Enterprise Function refresh can spend time waiting for execution
workers. Applications polling `job.status()` currently see `running`
during that wait. Return `waiting_for_capacity` when the server reports
that phase for an active Function refresh. The next status request
reports `running` when execution resumes. Applications can use
`job.wait()` to wait through both states until completion.

Rust, Python and Node read the phase from the existing job description
response.

## Validation

Two HTTP regression tests exercise the public job handle. They cover the
wait, work resuming, completion after another wait, a stale phase at
completion, queued and paused refreshes, other job types, and servers
that omit the phase. The Rust CI remote job runs these tests.
This commit is contained in:
Yang Cen
2026-11-22 16:00:50 +08:00
committed by GitHub
parent 08ddcdb7d7
commit d9b49e8889
7 changed files with 104 additions and 24 deletions
+7 -6
View File
@@ -316,8 +316,9 @@ class AsyncJob(Generic[T]):
return self._inner.id if self._inner is not None else None
async def status(self) -> str:
"""The operation's current lifecycle state: "running", "finished",
"failed", or "cancelled".
"""Return the current status, usually "running", "finished", "failed",
or "cancelled". A Function refresh waiting for execution workers reports
"waiting_for_capacity".
A point snapshot; unlike `wait` it does not block or raise on a
terminal failure state. States a newer server reports that this
@@ -384,8 +385,7 @@ class AsyncJob(Generic[T]):
Queue metadata and counters are included when supplied by the server.
Older servers may
omit counters, and in-process operations return ``None``. A missing
counter is unknown rather than zero. This is additive to :meth:`status`,
whose string contract is unchanged.
counter is unknown rather than zero.
"""
if self._inner is None:
return None
@@ -1070,8 +1070,9 @@ class Job(Generic[T]):
return self._inner._id if self._inner is not None else None
def status(self) -> str:
"""The operation's current lifecycle state: "running", "finished",
"failed", or "cancelled".
"""Return the current status, usually "running", "finished", "failed",
or "cancelled". A Function refresh waiting for execution workers reports
"waiting_for_capacity".
See :meth:`AsyncJob.status`.
"""