(groupJid: string)
| 68 | } |
| 69 | |
| 70 | enqueueMessageCheck(groupJid: string): void { |
| 71 | if (this.shuttingDown) return; |
| 72 | |
| 73 | const state = this.getGroup(groupJid); |
| 74 | |
| 75 | if (state.active) { |
| 76 | state.pendingMessages = true; |
| 77 | logger.debug({ groupJid }, 'Container active, message queued'); |
| 78 | return; |
| 79 | } |
| 80 | |
| 81 | if (this.activeCount >= MAX_CONCURRENT_CONTAINERS) { |
| 82 | state.pendingMessages = true; |
| 83 | if (!this.waitingGroups.includes(groupJid)) { |
| 84 | this.waitingGroups.push(groupJid); |
| 85 | } |
| 86 | logger.debug( |
| 87 | { groupJid, activeCount: this.activeCount }, |
| 88 | 'At concurrency limit, message queued', |
| 89 | ); |
| 90 | return; |
| 91 | } |
| 92 | |
| 93 | this.runForGroup(groupJid, 'messages').catch((err) => |
| 94 | logger.error({ groupJid, err }, 'Unhandled error in runForGroup'), |
| 95 | ); |
| 96 | } |
| 97 | |
| 98 | enqueueTask(groupJid: string, taskId: string, fn: () => Promise<void>): void { |
| 99 | if (this.shuttingDown) return; |
no test coverage detected