-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
16 changed files
with
230 additions
and
98 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { Message } from '@aws-sdk/client-sqs' | ||
import { randomUUID } from 'node:crypto' | ||
|
||
import { QueueComponent, QueueMessage } from '../types' | ||
|
||
export function createInMemoryQueue(): QueueComponent { | ||
const queue: Map<string, Message> = new Map() | ||
|
||
async function send(message: QueueMessage): Promise<void> { | ||
const receiptHandle = randomUUID().toString() | ||
queue.set(receiptHandle, { | ||
MessageId: randomUUID().toString(), | ||
ReceiptHandle: receiptHandle, | ||
Body: JSON.stringify({ Message: JSON.stringify(message) }) | ||
}) | ||
|
||
return | ||
} | ||
|
||
async function receiveSingleMessage(): Promise<Message[]> { | ||
return queue.size > 0 ? [queue.values().next().value] : [] | ||
} | ||
|
||
async function deleteMessage(receiptHandle: string): Promise<void> { | ||
queue.delete(receiptHandle) | ||
} | ||
|
||
return { send, receiveSingleMessage, deleteMessage } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
10 changes: 5 additions & 5 deletions
10
consumer-server/src/logic/entity-fetcher.ts → consumer-server/src/logic/scene-fetcher.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,23 @@ | ||
import { createCatalystClient } from 'dcl-catalyst-client' | ||
|
||
import { AppComponents, EntityFetcherComponent } from '../types' | ||
import { AppComponents, SceneFetcherComponent } from '../types' | ||
|
||
export async function createEntityFetcherComponent({ | ||
logs, | ||
fetcher | ||
}: Pick<AppComponents, 'logs' | 'fetcher'>): Promise<EntityFetcherComponent> { | ||
}: Pick<AppComponents, 'logs' | 'fetcher'>): Promise<SceneFetcherComponent> { | ||
const logger = logs.getLogger('entity-fetcher') | ||
const contentClient = await createCatalystClient({ url: 'https://peer.decentraland.org', fetcher }).getContentClient() | ||
|
||
async function fetchEntities(entityIds: string[]) { | ||
async function fetchByPointers(scenePointers: string[]) { | ||
try { | ||
const entities = await contentClient.fetchEntitiesByIds(entityIds) | ||
const entities = await contentClient.fetchEntitiesByPointers(scenePointers) | ||
return entities | ||
} catch (error: any) { | ||
logger.error('Failed while fetching entity', { error }) | ||
return null | ||
} | ||
} | ||
|
||
return { fetchEntities } | ||
return { fetchByPointers } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.