Delete lenient session ensure writer
This commit is contained in:
parent
e6fae8b076
commit
cd2177e834
4 changed files with 2 additions and 39 deletions
|
|
@ -291,7 +291,6 @@ pub use runtime_spine::coordinator_run_receipts;
|
|||
pub use runtime_spine::coordinator_run_session_id;
|
||||
pub use runtime_spine::create_runtime_job;
|
||||
pub use runtime_spine::create_runtime_session;
|
||||
pub use runtime_spine::ensure_runtime_session;
|
||||
pub use runtime_spine::finalize_coordinator_run;
|
||||
pub use runtime_spine::initialize_runtime_spine;
|
||||
pub use runtime_spine::model_pass_failure_for_request;
|
||||
|
|
|
|||
|
|
@ -1077,42 +1077,6 @@ pub fn create_runtime_session(
|
|||
Ok(session)
|
||||
}
|
||||
|
||||
pub fn ensure_runtime_session(
|
||||
store_path: impl AsRef<Path>,
|
||||
options: RuntimeSpineSessionOptions,
|
||||
) -> Result<EpiphanyRuntimeSession> {
|
||||
validate_non_empty(&options.session_id, "session id")?;
|
||||
validate_non_empty(&options.objective, "objective")?;
|
||||
validate_non_empty(&options.created_at, "created at")?;
|
||||
let mut cache = runtime_spine_cache(store_path.as_ref())?;
|
||||
cache.pull_all_backing_stores()?;
|
||||
require_identity(&cache)?;
|
||||
require_runtime_identity_not_archived(&cache, "session", &options.session_id)?;
|
||||
if let Some(existing) = cache.get::<EpiphanyRuntimeSession>(&options.session_id)? {
|
||||
if matches!(
|
||||
existing.status,
|
||||
EpiphanyRuntimeSessionStatus::Completed | EpiphanyRuntimeSessionStatus::Archived
|
||||
) {
|
||||
return Err(anyhow!(
|
||||
"runtime session {:?} is terminal and cannot accept jobs",
|
||||
options.session_id
|
||||
));
|
||||
}
|
||||
return Ok(existing);
|
||||
}
|
||||
let session = EpiphanyRuntimeSession {
|
||||
schema_version: RUNTIME_SPINE_SCHEMA_VERSION.to_string(),
|
||||
session_id: options.session_id.clone(),
|
||||
objective: options.objective,
|
||||
status: EpiphanyRuntimeSessionStatus::Active,
|
||||
created_at: options.created_at.clone(),
|
||||
updated_at: options.created_at,
|
||||
coordinator_note: options.coordinator_note,
|
||||
};
|
||||
cache.put(&options.session_id, &session)?;
|
||||
Ok(session)
|
||||
}
|
||||
|
||||
pub fn close_runtime_session(
|
||||
store_path: impl AsRef<Path>,
|
||||
options: RuntimeSpineSessionClosureOptions,
|
||||
|
|
|
|||
|
|
@ -1204,7 +1204,7 @@ mod tests {
|
|||
created_at: options.created_at.clone(),
|
||||
},
|
||||
)?;
|
||||
epiphany_core::ensure_runtime_session(
|
||||
epiphany_core::create_runtime_session(
|
||||
store,
|
||||
epiphany_core::RuntimeSpineSessionOptions {
|
||||
session_id: options.session_id.clone(),
|
||||
|
|
|
|||
|
|
@ -2463,7 +2463,7 @@ mod tests {
|
|||
created_at: options.created_at.clone(),
|
||||
},
|
||||
)?;
|
||||
epiphany_core::ensure_runtime_session(
|
||||
epiphany_core::create_runtime_session(
|
||||
store,
|
||||
epiphany_core::RuntimeSpineSessionOptions {
|
||||
session_id: options.session_id.clone(),
|
||||
|
|
|
|||
Reference in a new issue