Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: debug message handling #25

Merged
merged 1 commit into from
Jan 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion consumer-server/src/logic/lod-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,14 @@ export function createLodGeneratorComponent(): LodGeneratorService {
return files
}

return { generate }
async function mockGenerate(entityId: string, basePointer: string): Promise<string[]> {

if (entityId === "test"){
return await generate('test', 'test')
} else {
return ['0.glb', '1.glb', '2.glb']
}
}

return { generate: mockGenerate }
}
6 changes: 3 additions & 3 deletions consumer-server/src/logic/message-consumer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,11 @@ export async function createMessagesConsumerComponent({
id: MessageId!,
message: parsedMessage.Message
})
await messageHandler.handle(parsedMessage)
await messageHandler.handle(JSON.parse(parsedMessage.Message))
} catch (error: any) {
console.log({ error })
logger.error('Failed while handling message from queue', {
id: MessageId!,
error
id: MessageId!
})
} finally {
await queue.deleteMessage(ReceiptHandle!)
Expand Down
17 changes: 9 additions & 8 deletions consumer-server/src/logic/message-handler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,21 +7,22 @@ export function createMessageHandlerComponent({
}: Pick<AppComponents, 'logs' | 'lodGenerator' | 'storage'>): MessageHandler {
const logger = logs.getLogger('message-handler')

async function handle(message: { Message: string }): Promise<void> {
const parsedMessage = JSON.parse(message.Message)
async function handle(message: any): Promise<void> {
console.log({ message })
logger.info('Handling', { type: message.type, id: message.entity.entityId })

logger.info('Handling message', { parsedMessage })
if (parsedMessage.entity.entityType !== 'scene') {
return
if (message.entity.entityType !== 'scene') {
return
}
logger.info('Handling message', { message })

const entityId = parsedMessage.entity.entityId
const base = parsedMessage.entity.metadata.scene.base
const entityId = message.entity.entityId
const base = message.entity.metadata.scene.base

try {
const filesToUpload = await lodGenerator.generate(entityId, base)
logger.info('LODs correctly generated', { files: filesToUpload.join(', '), entityId })
await storage.storeFiles(filesToUpload, base, parsedMessage.entity.entityTimestamp.toString())
// await storage.storeFiles(filesToUpload, base, parsedMessage.entity.entityTimestamp.toString())
} catch (error: any) {
logger.error('Failed while generating LODs', { error, entityId })
}
Expand Down
Loading