MCPcopy Create free account
hub / github.com/cloudflare/wildebeest / queue

Function queue

consumer/src/index.ts:23–54  ·  view source on GitHub ↗
(batch: MessageBatch<MessageBody>, env: Env, ctx: ExecutionContext)

Source from the content-addressed store, hash-verified

21
22export default {
23 async queue(batch: MessageBatch<MessageBody>, env: Env, ctx: ExecutionContext) {
24 const sentry = initSentryQueue(env, ctx)
25 const db = await getDatabase(env)
26
27 try {
28 for (const message of batch.messages) {
29 const actor = await actors.getActorById(db, new URL(message.body.actorId))
30 if (actor === null) {
31 console.warn(`actor ${message.body.actorId} is missing`)
32 return
33 }
34
35 switch (message.body.type) {
36 case MessageType.Inbox: {
37 await handleInboxMessage(env, actor, message.body as InboxMessageBody)
38 break
39 }
40 case MessageType.Deliver: {
41 await handleDeliverMessage(env, actor, message.body as DeliverMessageBody)
42 break
43 }
44 default:
45 throw new Error('unsupported message type: ' + message.body.type)
46 }
47 }
48 } catch (err: any) {
49 if (sentry !== null) {
50 sentry.captureException(err)
51 }
52 console.error(err.stack, err.cause)
53 }
54 },
55}

Callers

nothing calls this directly

Calls 4

initSentryQueueFunction · 0.90
getDatabaseFunction · 0.90
handleInboxMessageFunction · 0.90
handleDeliverMessageFunction · 0.90

Tested by

no test coverage detected