dataconnect(chore): factor out repeated logic for creating CoroutineScope objects#8151
Conversation
…tineScope() and CoroutineScope.createChildSupervisorScope() and modified the code base to use them This change improves the "dryness" of the code by factoring out repeated logic into helper methods. This will also benefit future code that also wants to create "child" CoroutineScope objects.
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 introduces a createChildSupervisorScope extension function in CoroutineUtils to standardize the creation of supervisor coroutine scopes. The refactoring of DataConnectBidiConnectStream, DataConnectCredentialsTokenManager, and LiveQuery to use this utility improves code clarity and removes unused imports and parameters. Feedback identifies redundant imports within CoroutineUtils.kt and suggests removing redundant throwable string interpolation in log messages where the exception is already provided as a separate argument.
…aconnect/CoroutineUtilsMoreHelpers
…aconnect/CoroutineUtilsMoreHelpers
This PR factors out repeated logic for creating
CoroutineScopeobjects in the Data Connect SDK by introducing new helper functions inCoroutineUtils. These helpers simplify the creation of childSupervisorScopeobjects while ensuring proper structured concurrency and exception handling.Highlights
createChildSupervisorCoroutineScopeand a correspondingCoroutineScopeextension function toCoroutineUtilsto automate child scope creation with aSupervisorJob.DataConnectBidiConnectStream,DataConnectCredentialsTokenManager, andLiveQueryto use the new helper functions, reducing boilerplate.nonBlockingCoroutineDispatcherparameters fromLiveQueryandFirebaseDataConnectImplas they were redundant with the parent scope's context.Changelog
Modified Files
CoroutineUtils.kt: AddedcreateChildSupervisorCoroutineScopeandcreateChildSupervisorScopeextension to streamline child supervisor scope creation.DataConnectBidiConnectStream.kt: Migrated to the newcreateChildSupervisorScopeextension function.DataConnectCredentialsTokenManager.kt: Migrated to the newcreateChildSupervisorScopeextension function.LiveQuery.kt: Migrated to the newcreateChildSupervisorScopeextension function and removed redundant dispatcher parameter.FirebaseDataConnectImpl.kt: Removed redundant dispatcher parameter when instantiatingLiveQuery.