File size: 1,739 Bytes
b1df986 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | /**
* 结果存储步骤
* 存储任务结果到 Redis
*/
import { storeJobResult } from '../../../../infrastructure/redis/job/redis-job-result-store'
import { ensureJobNotCancelled } from '../../../job/job-cancel'
import type { RenderResult } from './render-step-types'
import { createLogger } from '../../../../shared/logging/logger'
import { normalizeTimings } from '../../../../shared/time/timings'
import { getCurrentJobTokenUsage } from '../../../job/job-log-context'
import type { StoreJobResultOutcome } from '../../../job/job-types'
const logger = createLogger('StorageStep')
/**
* 存储结果
*/
export async function storeResult(
renderResult: RenderResult,
timings: Record<string, number>,
_clientId?: string
): Promise<StoreJobResultOutcome> {
const {
jobId,
outputMode,
code,
codeLanguage,
usedAI,
generationType,
quality,
videoUrl,
hardsubUrl,
imageUrls,
imageCount,
workspaceVideoPath,
workspaceImagePaths,
renderPeakMemoryMB
} = renderResult
const normalizedTimings = normalizeTimings(timings)
const tokenUsage = getCurrentJobTokenUsage()
await ensureJobNotCancelled(jobId)
const storeOutcome = await storeJobResult(jobId, {
status: 'completed',
data: {
outputMode,
videoUrl,
hardsubUrl,
imageUrls,
imageCount,
workspaceVideoPath,
workspaceImagePaths,
code,
codeLanguage,
usedAI,
quality: quality as any,
generationType: generationType as any,
renderPeakMemoryMB,
timings: normalizedTimings,
tokenUsage
}
})
logger.info('Result storage resolved', { jobId, outputMode, videoUrl, imageCount, storeOutcome })
return storeOutcome
}
|