(private channel: IpcChannel)
| 24 | private pending = new Map<string, (result: CoordinatorResult) => void>(); |
| 25 | |
| 26 | constructor(private channel: IpcChannel) { |
| 27 | this.channel.on('message', (message: any) => { |
| 28 | if (message?.type !== 'coordinator:result') return; |
| 29 | const resolve = this.pending.get(message.reqId); |
| 30 | if (resolve) { |
| 31 | this.pending.delete(message.reqId); |
| 32 | resolve(message); |
| 33 | } |
| 34 | }); |
| 35 | } |
| 36 | |
| 37 | shouldRun(key: string, ttlMs: number): Promise<boolean> { |
| 38 | const reqId = createID(); |