Skip to content

dataconnect(feat): Realtime query results now update the local cache#8220

Open
dconeybe wants to merge 3 commits into
mainfrom
dconeybe/dataconnect/RealtimeCacheUpdate1
Open

dataconnect(feat): Realtime query results now update the local cache#8220
dconeybe wants to merge 3 commits into
mainfrom
dconeybe/dataconnect/RealtimeCacheUpdate1

Conversation

@dconeybe
Copy link
Copy Markdown
Contributor

@dconeybe dconeybe commented May 27, 2026

This PR updates the realtime query mechanism in firebase-dataconnect to update the local offline cache as new results are received from the realtime stream. This ensures that the local cache is populated/refreshed with the latest query results returned in real time, making them available for subsequent offline queries.

Highlights

  • Realtime Cache Synchronization: RealtimeQueryManager now integrates with the DataConnectCache and automatically writes incoming realtime stream query results to the local cache.
Changelog
  • CHANGELOG.md
    • Updated to document the new behavior where realtime query results update the local cache.
  • DataConnectBidiConnectStream.kt
    • Propagates AuthUid? as a connection cookie in the GrpcBidiFlow.Event.Message stream.
    • Added an authUid field to ExecuteResponse to track the credentials under which the query was executed.
  • DataConnectGrpcRPCs.kt
    • Made the List<DataConnectProperties>.getEntityIdForPathFunction() utility method internal instead of private.
  • FirebaseDataConnectImpl.kt
    • Updated the constructor calls to pass DataConnectCache to the realtime query manager initialization.
  • RealtimeQueryManager.kt
    • Added a cache: DataConnectCache? parameter to the constructor.
    • In RealtimeQueryManager.subscribe, applied the updateCache operation to local subscriptions and refactored the identifier code to use calculateQueryId.
    • Implemented the updateCache operator to parse, extract, and write metadata and entity ID functions to the SQLite cache database.
  • GrpcBidiFlow.kt
    • Updated the Event and Event.Message signatures to accept and carry a generic ConnectionCookie (e.g. AuthUid?).
  • RealtimeQueryManagerUnitTest.kt
    • Updated the unit tests to pass null for the new cache parameter during RealtimeQueryManager instantiation.

… results from the realtime stream [no ci]

NOTE: TESTS MUST BE ADDED IN A FOLLOW-UP PR!
@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 updates realtime query results to write to the local cache as they are received. It propagates the AuthUid through GrpcBidiFlow and DataConnectBidiConnectStream to associate query results with the correct user credentials, and updates RealtimeQueryManager to write incoming data to the cache. The review feedback focuses on making the cache updates resilient to database exceptions. Specifically, the reviewer recommends wrapping the cache database operations in runCatching and logging any failures as warnings using the Logger instance, rather than letting exceptions propagate and crash the long-running realtime query subscription.

@github-actions
Copy link
Copy Markdown
Contributor

📝 PRs merging into main branch

Our 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.

@dconeybe dconeybe marked this pull request as ready for review May 27, 2026 23:07
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