Skip to content

dataconnect(chore): factor out repeated logic for creating CoroutineScope objects#8151

Open
dconeybe wants to merge 5 commits into
dconeybe/dataconnect/RealtimeRewire2from
dconeybe/dataconnect/CoroutineUtilsMoreHelpers
Open

dataconnect(chore): factor out repeated logic for creating CoroutineScope objects#8151
dconeybe wants to merge 5 commits into
dconeybe/dataconnect/RealtimeRewire2from
dconeybe/dataconnect/CoroutineUtilsMoreHelpers

Conversation

@dconeybe
Copy link
Copy Markdown
Contributor

@dconeybe dconeybe commented May 12, 2026

This PR factors out repeated logic for creating CoroutineScope objects in the Data Connect SDK by introducing new helper functions in CoroutineUtils. These helpers simplify the creation of child SupervisorScope objects while ensuring proper structured concurrency and exception handling.

Highlights

  • Added createChildSupervisorCoroutineScope and a corresponding CoroutineScope extension function to CoroutineUtils to automate child scope creation with a SupervisorJob.
  • Refactored DataConnectBidiConnectStream, DataConnectCredentialsTokenManager, and LiveQuery to use the new helper functions, reducing boilerplate.
  • Removed unnecessary nonBlockingCoroutineDispatcher parameters from LiveQuery and FirebaseDataConnectImpl as they were redundant with the parent scope's context.

Changelog

Modified Files
  • CoroutineUtils.kt: Added createChildSupervisorCoroutineScope and createChildSupervisorScope extension to streamline child supervisor scope creation.
  • DataConnectBidiConnectStream.kt: Migrated to the new createChildSupervisorScope extension function.
  • DataConnectCredentialsTokenManager.kt: Migrated to the new createChildSupervisorScope extension function.
  • LiveQuery.kt: Migrated to the new createChildSupervisorScope extension function and removed redundant dispatcher parameter.
  • FirebaseDataConnectImpl.kt: Removed redundant dispatcher parameter when instantiating LiveQuery.

dconeybe added 2 commits May 12, 2026 12:35
…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.
@gemini-code-assist
Copy link
Copy Markdown
Contributor

Using Gemini Code Assist

The 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 /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

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 .gemini/ folder in the base of the repository. Detailed instructions can be found here.

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.

@dconeybe
Copy link
Copy Markdown
Contributor Author

/gemini review

Copy link
Copy Markdown
Contributor

@gemini-code-assist gemini-code-assist Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

@dconeybe dconeybe marked this pull request as ready for review May 12, 2026 21:27
@dconeybe dconeybe requested a review from aashishpatil-g May 12, 2026 21:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant