dataconnect(feat): Realtime query results now update the local cache#8220
dataconnect(feat): Realtime query results now update the local cache#8220dconeybe wants to merge 3 commits into
Conversation
… results from the realtime stream [no ci] NOTE: TESTS MUST BE ADDED IN A FOLLOW-UP PR!
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 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.
📝 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. |
This PR updates the realtime query mechanism in
firebase-dataconnectto 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
RealtimeQueryManagernow integrates with theDataConnectCacheand automatically writes incoming realtime stream query results to the local cache.Changelog
AuthUid?as a connection cookie in theGrpcBidiFlow.Event.Messagestream.authUidfield toExecuteResponseto track the credentials under which the query was executed.List<DataConnectProperties>.getEntityIdForPathFunction()utility methodinternalinstead ofprivate.DataConnectCacheto the realtime query manager initialization.cache: DataConnectCache?parameter to the constructor.RealtimeQueryManager.subscribe, applied theupdateCacheoperation to local subscriptions and refactored the identifier code to usecalculateQueryId.updateCacheoperator to parse, extract, and write metadata and entity ID functions to the SQLite cache database.EventandEvent.Messagesignatures to accept and carry a genericConnectionCookie(e.g.AuthUid?).nullfor the newcacheparameter duringRealtimeQueryManagerinstantiation.