mirror of
https://github.com/lancedb/lancedb.git
synced 2026-11-26 12:33:59 +00:00
fix!: preserve job attempt lineage, retries, and lifecycle states
BREAKING CHANGE: JobDescription, JobEventsRequest, FunctionErrorsRequest, and FunctionErrors gain optional Rust metadata/cursor fields. Existing struct literals must initialize them; use None when unavailable. Preserve typed attempt state, pinned retry lineage, result decoders and freshness fences, and retained diagnostic paging across SDKs. Keep Python job data access method-only.
This commit is contained in:
+57
-2
@@ -52,6 +52,45 @@ impl Job {
|
||||
self.inner.id().map(str::to_string)
|
||||
}
|
||||
|
||||
#[napi(getter)]
|
||||
pub fn job_id(&self) -> Option<String> {
|
||||
self.inner.job_id()
|
||||
}
|
||||
|
||||
#[napi(getter)]
|
||||
pub fn operation_id(&self) -> Option<String> {
|
||||
self.inner.operation_id()
|
||||
}
|
||||
|
||||
#[napi(getter)]
|
||||
pub fn attempt(&self) -> Option<u32> {
|
||||
self.inner.attempt()
|
||||
}
|
||||
|
||||
#[napi(getter)]
|
||||
pub fn retry_of(&self) -> Option<String> {
|
||||
self.inner.retry_of()
|
||||
}
|
||||
|
||||
#[napi(getter)]
|
||||
pub fn lifecycle_state(&self) -> Option<String> {
|
||||
self.inner
|
||||
.lifecycle_state()
|
||||
.map(|state| state.as_str().to_string())
|
||||
}
|
||||
|
||||
#[napi(getter)]
|
||||
pub fn source_table_version(&self) -> Option<f64> {
|
||||
self.inner
|
||||
.source_table_version()
|
||||
.map(|version| version as f64)
|
||||
}
|
||||
|
||||
#[napi(getter)]
|
||||
pub fn execution_epoch(&self) -> Option<i64> {
|
||||
self.inner.execution_epoch()
|
||||
}
|
||||
|
||||
/// The operation's current lifecycle state: "running", "finished",
|
||||
/// "failed", or "cancelled".
|
||||
///
|
||||
@@ -137,6 +176,13 @@ impl Job {
|
||||
self.inner.cancel().await.default_error()
|
||||
}
|
||||
|
||||
#[napi(catch_unwind)]
|
||||
pub async fn retry(&self) -> napi::Result<Self> {
|
||||
Ok(Self {
|
||||
inner: Arc::new(self.inner.retry().await.default_error()?),
|
||||
})
|
||||
}
|
||||
|
||||
/// Ask the backend for this job's current state, and for a server-side job
|
||||
/// its full record, then cache it for the getters below.
|
||||
///
|
||||
@@ -190,10 +236,19 @@ impl Job {
|
||||
/// This job's recorded lifecycle events, as an Arrow IPC stream buffer.
|
||||
/// The TypeScript wrapper turns it into an Arrow table.
|
||||
#[napi(catch_unwind)]
|
||||
pub async fn events(&self, limit: Option<u32>, filter: Option<String>) -> napi::Result<Buffer> {
|
||||
pub async fn events(
|
||||
&self,
|
||||
limit: Option<u32>,
|
||||
filter: Option<String>,
|
||||
page_token: Option<String>,
|
||||
) -> napi::Result<Buffer> {
|
||||
let batches = self
|
||||
.inner
|
||||
.events(JobEventsRequest { limit, filter })
|
||||
.events(JobEventsRequest {
|
||||
limit,
|
||||
filter,
|
||||
page_token,
|
||||
})
|
||||
.await
|
||||
.default_error()?;
|
||||
batches_to_ipc_buffer(&batches)
|
||||
|
||||
@@ -661,6 +661,7 @@ impl Table {
|
||||
job_id: options.job_id,
|
||||
column: options.column,
|
||||
limit,
|
||||
page_token: options.page_token,
|
||||
};
|
||||
let errors = self
|
||||
.inner_ref()?
|
||||
@@ -1845,6 +1846,8 @@ pub struct FunctionErrorsOptions {
|
||||
pub column: Option<String>,
|
||||
/// At most this many records (server default 10000, cap 100000).
|
||||
pub limit: Option<i64>,
|
||||
/// Empty starts retained history, including repaired rows, for an exact jobId; otherwise continue that page.
|
||||
pub page_token: Option<String>,
|
||||
}
|
||||
|
||||
/// Aggregate worker resources for one Enterprise Function refresh.
|
||||
@@ -2204,6 +2207,8 @@ pub struct FunctionErrors {
|
||||
pub fragments: Vec<FunctionErrorFragment>,
|
||||
/// Whether the listing stopped at its limit.
|
||||
pub truncated: bool,
|
||||
/// Continue the same job/filter. Absent for complete pages and older servers.
|
||||
pub page_token: Option<String>,
|
||||
}
|
||||
|
||||
/// One exact immutable Function revision attached to a table output.
|
||||
@@ -2322,6 +2327,7 @@ impl From<lancedb::function::FunctionErrors> for FunctionErrors {
|
||||
records: errors.records.into_iter().map(Into::into).collect(),
|
||||
fragments: errors.fragments.into_iter().map(Into::into).collect(),
|
||||
truncated: errors.truncated,
|
||||
page_token: errors.page_token,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user