扩展外部生成Worker队列
新增外部生成队列概览和单任务状态契约 将跳一跳、拼消消、敲木鱼图片生成动作接入worker队列 前端生成等待页展示当前任务和队列数量 更新外部生成worker运维文档和团队决策记录
This commit is contained in:
@@ -119,6 +119,53 @@ impl SpacetimeClient {
|
||||
action_type: payload.action_type,
|
||||
session,
|
||||
work,
|
||||
queue_state: None,
|
||||
})
|
||||
}
|
||||
|
||||
pub async fn mark_wooden_fish_generation_queued(
|
||||
&self,
|
||||
session_id: String,
|
||||
owner_user_id: String,
|
||||
author_display_name: String,
|
||||
payload: WoodenFishActionRequest,
|
||||
) -> Result<WoodenFishActionResponse, SpacetimeClientError> {
|
||||
let current = self
|
||||
.get_wooden_fish_session(session_id.clone(), owner_user_id.clone())
|
||||
.await?;
|
||||
let action_type = payload.action_type.clone();
|
||||
let scope = match action_type {
|
||||
WoodenFishActionType::CompileDraft => WoodenFishDraftMergeScope::CompileDraft,
|
||||
WoodenFishActionType::RegenerateHitObject => {
|
||||
WoodenFishDraftMergeScope::RegenerateHitObject
|
||||
}
|
||||
_ => {
|
||||
return Err(SpacetimeClientError::validation_failed(
|
||||
"wooden-fish queued generation 只支持 compile-draft/regenerate-hit-object",
|
||||
));
|
||||
}
|
||||
};
|
||||
let mut draft = merge_action_into_draft(current.draft.clone(), &payload, scope)?;
|
||||
let profile_id =
|
||||
resolve_wooden_fish_profile_id(&draft, &action_type, payload.profile_id.as_deref())?;
|
||||
draft.profile_id = Some(profile_id.clone());
|
||||
draft.generation_status = WoodenFishGenerationStatus::Generating;
|
||||
let session = self
|
||||
.compile_wooden_fish_draft(build_generating_compile_input(
|
||||
¤t,
|
||||
&owner_user_id,
|
||||
&author_display_name,
|
||||
&profile_id,
|
||||
&draft,
|
||||
current_unix_micros(),
|
||||
)?)
|
||||
.await?;
|
||||
|
||||
Ok(WoodenFishActionResponse {
|
||||
action_type,
|
||||
session,
|
||||
work: None,
|
||||
queue_state: None,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -689,6 +736,52 @@ fn build_compile_input(
|
||||
})
|
||||
}
|
||||
|
||||
fn build_generating_compile_input(
|
||||
current: &WoodenFishSessionSnapshotResponse,
|
||||
owner_user_id: &str,
|
||||
author_display_name: &str,
|
||||
profile_id: &str,
|
||||
draft: &WoodenFishDraftResponse,
|
||||
now_micros: i64,
|
||||
) -> Result<WoodenFishDraftCompileInput, SpacetimeClientError> {
|
||||
Ok(WoodenFishDraftCompileInput {
|
||||
session_id: current.session_id.clone(),
|
||||
owner_user_id: owner_user_id.to_string(),
|
||||
profile_id: profile_id.to_string(),
|
||||
author_display_name: author_display_name.trim().to_string(),
|
||||
work_title: draft.work_title.clone(),
|
||||
work_description: draft.work_description.clone(),
|
||||
theme_tags_json: Some(json_string(&draft.theme_tags)?),
|
||||
hit_object_prompt: draft.hit_object_prompt.clone(),
|
||||
hit_object_reference_image_src: draft.hit_object_reference_image_src.clone(),
|
||||
hit_sound_prompt: draft.hit_sound_prompt.clone(),
|
||||
hit_object_asset_json: draft
|
||||
.hit_object_asset
|
||||
.as_ref()
|
||||
.map(json_string)
|
||||
.transpose()?,
|
||||
background_asset_json: draft
|
||||
.background_asset
|
||||
.as_ref()
|
||||
.map(json_string)
|
||||
.transpose()?,
|
||||
hit_sound_asset_json: draft
|
||||
.hit_sound_asset
|
||||
.as_ref()
|
||||
.map(json_string)
|
||||
.transpose()?,
|
||||
back_button_asset_json: draft
|
||||
.back_button_asset
|
||||
.as_ref()
|
||||
.map(json_string)
|
||||
.transpose()?,
|
||||
floating_words_json: Some(json_string(&draft.floating_words)?),
|
||||
cover_image_src: draft.cover_image_src.clone(),
|
||||
generation_status: Some("generating".to_string()),
|
||||
compiled_at_micros: now_micros,
|
||||
})
|
||||
}
|
||||
|
||||
fn build_failed_compile_input(
|
||||
current: &WoodenFishSessionSnapshotResponse,
|
||||
owner_user_id: &str,
|
||||
|
||||
Reference in New Issue
Block a user