扩展外部生成Worker队列
新增外部生成队列概览和单任务状态契约 将跳一跳、拼消消、敲木鱼图片生成动作接入worker队列 前端生成等待页展示当前任务和队列数量 更新外部生成worker运维文档和团队决策记录
This commit is contained in:
@@ -124,6 +124,51 @@ impl SpacetimeClient {
|
||||
action_type: payload.action_type,
|
||||
session,
|
||||
work,
|
||||
queue_state: None,
|
||||
})
|
||||
}
|
||||
|
||||
pub async fn mark_puzzle_clear_generation_queued(
|
||||
&self,
|
||||
session_id: String,
|
||||
owner_user_id: String,
|
||||
author_display_name: String,
|
||||
payload: PuzzleClearActionRequest,
|
||||
) -> Result<PuzzleClearActionResponse, SpacetimeClientError> {
|
||||
let current = self
|
||||
.get_puzzle_clear_session(session_id.clone(), owner_user_id.clone())
|
||||
.await?;
|
||||
let action_type = payload.action_type.clone();
|
||||
let scope = match action_type {
|
||||
PuzzleClearActionType::CompileDraft => PuzzleClearDraftMergeScope::CompileDraft,
|
||||
PuzzleClearActionType::RegenerateAtlas => PuzzleClearDraftMergeScope::RegenerateAtlas,
|
||||
_ => {
|
||||
return Err(SpacetimeClientError::validation_failed(
|
||||
"puzzle-clear queued generation 只支持 compile-draft/regenerate-atlas",
|
||||
));
|
||||
}
|
||||
};
|
||||
let mut draft = merge_action_into_draft(current.draft.clone(), &payload, scope)?;
|
||||
let profile_id =
|
||||
resolve_puzzle_clear_profile_id(&draft, &action_type, payload.profile_id.as_deref())?;
|
||||
draft.profile_id = Some(profile_id.clone());
|
||||
draft.generation_status = PuzzleClearGenerationStatus::Generating;
|
||||
let session = self
|
||||
.compile_puzzle_clear_draft(build_generating_compile_input(
|
||||
¤t,
|
||||
&owner_user_id,
|
||||
&author_display_name,
|
||||
&profile_id,
|
||||
&draft,
|
||||
current_unix_micros(),
|
||||
)?)
|
||||
.await?;
|
||||
|
||||
Ok(PuzzleClearActionResponse {
|
||||
action_type,
|
||||
session,
|
||||
work: None,
|
||||
queue_state: None,
|
||||
})
|
||||
}
|
||||
|
||||
@@ -647,6 +692,38 @@ fn build_compile_input(
|
||||
})
|
||||
}
|
||||
|
||||
fn build_generating_compile_input(
|
||||
current: &PuzzleClearSessionSnapshotResponse,
|
||||
owner_user_id: &str,
|
||||
author_display_name: &str,
|
||||
profile_id: &str,
|
||||
draft: &PuzzleClearDraftResponse,
|
||||
now_micros: i64,
|
||||
) -> Result<PuzzleClearDraftCompileInput, SpacetimeClientError> {
|
||||
Ok(PuzzleClearDraftCompileInput {
|
||||
session_id: current.session_id.clone(),
|
||||
owner_user_id: owner_user_id.to_string(),
|
||||
profile_id: profile_id.to_string(),
|
||||
author_display_name: non_empty_str(author_display_name)
|
||||
.unwrap_or_else(|| "拼消消玩家".to_string()),
|
||||
work_title: draft.work_title.clone(),
|
||||
work_description: draft.work_description.clone(),
|
||||
theme_prompt: draft.theme_prompt.clone(),
|
||||
board_background_prompt: draft.board_background_prompt.clone(),
|
||||
generate_board_background: draft.generate_board_background,
|
||||
board_background_asset_json: draft
|
||||
.board_background_asset
|
||||
.as_ref()
|
||||
.map(json_string)
|
||||
.transpose()?,
|
||||
atlas_asset_json: draft.atlas_asset.as_ref().map(json_string).transpose()?,
|
||||
pattern_groups_json: Some(json_string(&draft.pattern_groups)?),
|
||||
card_assets_json: Some(json_string(&draft.card_assets)?),
|
||||
generation_status: Some("generating".to_string()),
|
||||
compiled_at_micros: now_micros,
|
||||
})
|
||||
}
|
||||
|
||||
fn build_failed_compile_input(
|
||||
current: &PuzzleClearSessionSnapshotResponse,
|
||||
owner_user_id: &str,
|
||||
|
||||
Reference in New Issue
Block a user