dataconnect(change): add exponential backoff in realtime query subscriptions upon disconnecting from the server#8381
dataconnect(change): add exponential backoff in realtime query subscriptions upon disconnecting from the server#8381dconeybe wants to merge 7 commits into
Conversation
Using Gemini Code AssistThe full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips. Invoking Gemini You can request assistance from Gemini at any point by creating a comment using either
Customization To customize the Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a Limitations & Feedback Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counterproductive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for GitHub and other Google products, sign up here. |
|
/gemini review |
There was a problem hiding this comment.
Code Review
This pull request implements an exponential backoff strategy for retrying realtime query subscription connections. It introduces a thread-safe RetryBackoffCalculator class to compute backoff durations starting at 1000ms with a 1.75 multiplier up to a maximum of 600,000ms. It also adds a clear() method to ConflatedSignal to discard pending signals, and updates DataConnectBidiConnectStream to utilize these components. Comprehensive unit tests have been added to verify the backoff calculation, signal clearing, and overall retry behaviors under various scenarios. I have no feedback to provide as there are no review comments.
📝 PRs merging into main branchOur main branch should always be in a releasable state. If you are working on a larger change, or if you don't want this change to see the light of the day just yet, consider using a feature branch first, and only merge into the main branch when the code complete and ready to be released. |
Introduce exponential backoff retry strategy for Data Connect realtime query subscriptions when they disconnect or fail to connect. When connection failures occur, the client backs off progressively before retrying, but resets the delay on successful messages, immediate retry triggers, or when a new subscription is registered.
Highlights
RetryBackoffCalculator) capped at 10 minutes (600,000ms), using a multiplier of 1.75.clear()method toConflatedSignalto allow discarding pending signals, which is utilized to manage retry and wakeup events cleanly.Changelog
clear()method to discard any pending signals, causing subsequent calls toawaitto suspend until a new signal is emitted.RetryBackoffCalculatorand aConflatedSignalevent to handle retries and immediate wakeup actions.RetryBackoffCalculatornext value progression, max value ceiling, reset functionality, and thread-safety under concurrent access.clear()method.