feat(nodejs): pause and resume jobs from the TypeScript SDK (#4113)

Companion to #4112: `pauseJob` and `resumeJob` on `Connection`, posting
to the server's `/v1/jobs/pause` and `/v1/jobs/resume` endpoints. A
pause parks the job until it is resumed: its workers drain and stop, and
a resume re-queues it to pick work back up from checkpoints.

The outcome strings mirror the server's answers — `"pausing"`,
`"already_paused"`, or `"committing"` (a job finalizing its results
cannot be parked; retry shortly), and `"resumed"`, `"still_pausing"`, or
`"not_paused"` — so a caller can retry the transient refusals rather
than treat them as failures.

Stacked on #4112 (shares the Rust core change); draft until the
server-side endpoints reach production.
This commit is contained in:
Wyatt Alt
2026-09-24 02:35:03 +08:00
committed by GitHub
parent 1fc72427e3
commit 2ebd6142e4
4 changed files with 119 additions and 0 deletions
+28
View File
@@ -583,6 +583,34 @@ impl Connection {
self.get_inner()?.cancel_job(&job_id).await.default_error()
}
/// Pause a server-side job by id: its workers drain and it stays parked
/// until resumed. Returns "pausing", "already_paused", or "committing".
#[napi(catch_unwind)]
pub async fn pause_job(&self, job_id: String) -> napi::Result<String> {
let status = self.get_inner()?.pause_job(&job_id).await.default_error()?;
Ok(match status {
lancedb::database::PauseJobStatus::Pausing => "pausing".to_string(),
lancedb::database::PauseJobStatus::AlreadyPaused => "already_paused".to_string(),
lancedb::database::PauseJobStatus::Committing => "committing".to_string(),
})
}
/// Resume a paused server-side job by id. Returns "resumed",
/// "still_pausing", or "not_paused".
#[napi(catch_unwind)]
pub async fn resume_job(&self, job_id: String) -> napi::Result<String> {
let status = self
.get_inner()?
.resume_job(&job_id)
.await
.default_error()?;
Ok(match status {
lancedb::database::ResumeJobStatus::Resumed => "resumed".to_string(),
lancedb::database::ResumeJobStatus::StillPausing => "still_pausing".to_string(),
lancedb::database::ResumeJobStatus::NotPaused => "not_paused".to_string(),
})
}
#[napi(catch_unwind)]
/// Describe a namespace and return its properties.
pub async fn describe_namespace(