-
Notifications
You must be signed in to change notification settings - Fork 7
Avoid starting consumers prematurely #392
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
📝 WalkthroughWalkthroughAdds resource-readiness tracking and a deferred/non-blocking startup flow for SNS/SQS consumers, extracts consumer startup into a dedicated method, tightens a couple of TypeScript assertions, and adds tests covering blocking and non-blocking startup scenarios. Changes
Sequence Diagram(s)sequenceDiagram
participant Caller as Caller
participant Consumer as AbstractSnsSqsConsumer
participant Initter as initSnsSqs / snsInitter
participant AWS as SNS/SQS (AWS)
participant Callback as onResourcesReady
Caller->>Consumer: start()
alt blocking mode or resourcesReady==true
Consumer->>Initter: initSnsSqs() / init()
Initter->>AWS: ensure topic & queue exist (may create)
AWS-->>Initter: topicArn / queueUrl
Initter->>Callback: onResourcesReady(topicArn, queueUrl, ...)
Callback->>Consumer: set resourcesReady = true, update ARNs/URLs/names
Consumer->>Consumer: startConsumers()
Consumer->>AWS: poll messages (SQS consumers)
else non-blocking mode & resources not ready
Consumer->>Initter: initSnsSqs() (returns pending)
Consumer->>Caller: return immediately (startRequested=true)
AWS-->>Initter: topicArn / queueUrl (when ready)
Initter->>Callback: onResourcesReady(...)
Callback->>Consumer: set resourcesReady = true
alt startRequested was set
Consumer->>Consumer: startConsumers()
end
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~22 minutes Possibly related PRs
Suggested labels
Suggested reviewers
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches
📜 Recent review detailsConfiguration used: defaults Review profile: CHILL Plan: Pro 📒 Files selected for processing (3)
🚧 Files skipped from review as they are similar to previous changes (1)
🧰 Additional context used🧬 Code graph analysis (1)packages/sns/test/consumers/SnsSqsPermissionConsumer.startupResourcePolling.spec.ts (2)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (19)
🔇 Additional comments (2)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Summary by CodeRabbit
New Features
Refactor
Tests
✏️ Tip: You can customize this high-level summary in your review settings.