(batch: MessageBatch<MessageBody>, env: Env, ctx: ExecutionContext)
| 21 | |
| 22 | export 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 | } |
nothing calls this directly
no test coverage detected