Skip to content

Commit

Permalink
feat: modify workflow to pass individual file links
Browse files Browse the repository at this point in the history
  • Loading branch information
aleortega committed Mar 4, 2024
1 parent e638f57 commit f225da0
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 14 deletions.
4 changes: 2 additions & 2 deletions consumer-server/src/components.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,8 +30,8 @@ export async function initComponents(): Promise<AppComponents> {

const sqsQueue = await config.getString('TASK_QUEUE')
const taskQueue = sqsQueue ?
createSqsAdapter<DeploymentToSqs & { lodBucketDirectory: string | undefined }>({ logs, metrics }, { queueUrl: sqsQueue, queueRegion: AWS_REGION }) :
createMemoryQueueAdapter<DeploymentToSqs & { lodBucketDirectory: string | undefined }>({ logs, metrics }, { queueName: "ConversionTaskQueue" })
createSqsAdapter<DeploymentToSqs & { lods: string[] | undefined }>({ logs, metrics }, { queueUrl: sqsQueue, queueRegion: AWS_REGION }) :
createMemoryQueueAdapter<DeploymentToSqs & { lods: string[] | undefined }>({ logs, metrics }, { queueName: "ConversionTaskQueue" })

const s3Bucket = await config.getString('CDN_BUCKET')
const cdnS3 = s3Bucket ? new AWS.S3({}) : new MockAws.S3({})
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export async function queueTaskHandler(context: HandlerContextWithPath<"metrics"

if (!DeploymentToSqs.validate(body)) return { status: 403, body: { errors: DeploymentToSqs.validate.errors } }

const message = await taskQueue.publish(body as DeploymentToSqs & { lodBucketDirectory: string | undefined; })
const message = await taskQueue.publish(body as DeploymentToSqs & { lods: string[] | undefined; })

return {
status: 201,
Expand Down
7 changes: 3 additions & 4 deletions consumer-server/src/logic/conversion-task.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ function getAbVersionEnvName(buildTarget: string)
}
}

export async function executeLODConversion(components: Pick<AppComponents, 'logs' | 'metrics' | 'config' | 'cdnS3'>, entityId: string, lodBucketDirectory: string) {
export async function executeLODConversion(components: Pick<AppComponents, 'logs' | 'metrics' | 'config' | 'cdnS3'>, entityId: string, lods: string[]) {
const $LOD_BUCKET = await components.config.getString('LOD_BUCKET')
if (!$LOD_BUCKET) {
throw new Error('LOD_BUCKET is not defined')
Expand All @@ -92,7 +92,7 @@ export async function executeLODConversion(components: Pick<AppComponents, 'logs
const logFile = `/tmp/asset_bundles_logs/export_log_${entityId}_${Date.now()}.txt`
const s3LogKey = `logs/${$AB_VERSION}/${entityId}/${new Date().toISOString()}.txt`
const outDirectory = `/tmp/asset_bundles_contents/entity_${entityId}`
let defaultLoggerMetadata = { entityId, lodBucketDirectory, version: $AB_VERSION, logFile } as any
let defaultLoggerMetadata = { entityId, lods, version: $AB_VERSION, logFile } as any

logger.info("Starting conversion for " + $BUILD_TARGET, defaultLoggerMetadata)

Expand All @@ -101,8 +101,7 @@ export async function executeLODConversion(components: Pick<AppComponents, 'logs
entityId,
logFile,
outDirectory,
lodBucket: $LOD_BUCKET,
lodBucketDirectory,
lods,
unityPath: $UNITY_PATH,
projectPath: $PROJECT_PATH,
timeout: 60 * 60 * 1000,
Expand Down
6 changes: 2 additions & 4 deletions consumer-server/src/logic/run-conversion.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,7 @@ export async function runLodsConversion(logger: ILoggerComponent.ILogger, compon
logFile: string,
outDirectory: string,
entityId: string,
lodBucket: string,
lodBucketDirectory: string,
lods: string[],
unityPath: string,
projectPath: string,
timeout: number
Expand All @@ -61,8 +60,7 @@ export async function runLodsConversion(logger: ILoggerComponent.ILogger, compon
'-executeMethod', 'DCL.ABConverter.LODClient.ExportS3LODsToAssetBundles',
'-sceneCid', options.entityId,
'-logFile', options.logFile,
'-bucket', options.lodBucket,
'-bucketDirectory', options.lodBucketDirectory,
'-lods', options.lods.join(','),
'-output', options.outDirectory
]

Expand Down
4 changes: 2 additions & 2 deletions consumer-server/src/service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ export async function main(program: Lifecycle.EntryPointParameters<AppComponents
await components.taskQueue.consumeAndProcessJob(async (job, message) => {
try {
components.metrics.increment('ab_converter_running_conversion')
if (job.lodBucketDirectory) {
await executeLODConversion(components, job.entity.entityId, job.lodBucketDirectory)
if (job.lods) {
await executeLODConversion(components, job.entity.entityId, job.lods)
} else {
await executeConversion(components, job.entity.entityId, job.contentServerUrls![0], job.force)
}
Expand Down
2 changes: 1 addition & 1 deletion consumer-server/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ export type BaseComponents = {
logs: ILoggerComponent
server: IHttpServerComponent<GlobalContext>
fetch: IFetchComponent
taskQueue: ITaskQueue<DeploymentToSqs & { lodBucketDirectory: string | undefined }>
taskQueue: ITaskQueue<DeploymentToSqs & { lods: string[] | undefined }>
metrics: IMetricsComponent<keyof typeof metricDeclarations>
cdnS3: S3
runner: IRunnerComponent
Expand Down

0 comments on commit f225da0

Please sign in to comment.