refactor(worker): move coexist jobs to dedicated heavy worker - #1067
Draft
viethung0o0 wants to merge 2 commits into
Draft
refactor(worker): move coexist jobs to dedicated heavy worker#1067viethung0o0 wants to merge 2 commits into
viethung0o0 wants to merge 2 commits into
Conversation
This file contains hidden or 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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
coexistWhatsappBuffer/Flush,coexistMessengerSync,coexistInstagramSync,coexistAttachmentDownload) off theintegrationqueue onto a new workload-classheavyqueue with its own worker, so long-running Graph-API sync chunks no longer occupy the concurrency slots that real-time chat jobs (incomingMessage,sendFlow) need.heavyqueue is a generic tier for long-lock, throughput-oriented jobs — coexist is its first tenant; future heavy workloads (e.g. import backfills) join it instead of spawning new workers.bull:integrationafter deploy (forwards them to the heavy queue preserving jobId and options);scripts/check-coexist-drain.mtsgates a follow-up PR that deletes the shim once the old queue is clean. ItsstalledIntervaloverride is also removed so crashed-worker jobs are re-picked in seconds.Changes
packages/worker-config/src/queues/heavy/— newheavyqueue module:HeavyJobAction,HeavyJobData(+ runtimeheavyJobDataSchema),heavyQueue; the 5 actions removed from the integration queue module.apps/worker/src/heavy/— new worker (blocked-owner guard, audit context, 10-min lock sized for sync chunks,HEAVY_WORKER_CONCURRENCYenv) with the coexist handlers moved underhandlers/coexist/(git renames, history preserved); all coexist follow-up enqueues retargetheavyQueue(updateContactAvatarfan-out stays onintegration).apps/worker/src/integration/worker.ts— coexist cases/handler imports removed; forward-only legacy shim added; lock comment re-derived fromCHAT_JOB_WAIT_TIMEOUT_MS;stalledIntervaloverride dropped.apps/worker/src/schedule/handlers/scan-coexist-runs.ts,packages/business/src/coexist/service.ts— enqueue/strategy types retarget the heavy queue (jobId schemes unchanged).packages/sdk+integrations/whatsapp—HandleRequestPropsgains a generic optionalheavyQueue; the WhatsApp webhook enqueues the coexist buffer through it and logs an error if it is missing; both builder webhook routes inject it.apps/builder/src/app/developer/queues/**— heavy queue registered in the queues dashboard.scripts/check-coexist-drain.mts— read-only drain gate for removing the legacy shim later.heavyQueuewiring,heavyJobDataSchema, build-phase fake queue, docker entrypoint roster.Test plan
pnpm lintcheck-typesforworker,builder,@chatbotx.io/worker-config,@chatbotx.io/business,@chatbotx.io/sdk,@chatbotx.io/integration-whatsapppnpm --filter worker test(194 files, 1841 tests)pnpm --filter builder test(312 files, 2027 tests)pnpm --filter @chatbotx.io/business test(1527 tests),@chatbotx.io/worker-config(25),@chatbotx.io/integration-whatsapp(215)apps/workertsdown build producesdist/heavy/worker.mjs(docker entrypoint auto-discovers it)scripts/check-coexist-drain.mtsruns clean against local Redisbull:heavyand history imports completepnpm tsx scripts/check-coexist-drain.mts; when clean, open the follow-up PR removing the legacy shim + script