forked from cachapa/firedart
-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: add transactions #1
Draft
jsgalarraga
wants to merge
11
commits into
master
Choose a base branch
from
feat/add-transactions
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
alestiago
reviewed
Jul 5, 2024
alestiago
reviewed
Jul 5, 2024
When will this feature be merged? |
evandrobubiak
approved these changes
Nov 5, 2024
@evandrobubiak You can see the progress (or I should say lack of progress 🥲) on the PR opened in the official repo. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Dummy PR to make easier to see changes
This PR introduces Firestore transactions to the package.
Why
Transactions are a powerful feature to have in the backend. This is an effort to have a more complete feature set for a dart backend.
It has been requested by users in cachapa#63 and cachapa#126.
Inspiration
The work here has been inspired by:
Transaction
class that exposes the methods that can be performed.Implementation notes
Transaction
class, does not extend the existingReference
even though it needs some of its methods because aTransaction
does not have a predefinedpath
. The_fullPath
and_encodeMap
methods have been adapted.mutations
in aTransaction
have to be exposed for theFirestoreGateway
to have access to them and run the transactioncommit
. To safely do this, it is kept as anUnmodifiableListView
to prevent the end user from modifying it.GrpcError
withStatusCode.aborted
is thrown. In this PR, the error handling is implemented to retry the transaction up to 5 times by default (as the other firestore SDKs do).Examples
To ensure transactions are working and keeping the database consistent with all the write operations performed in parallel, the following test has been run: Increase a value multiple times both with and without transactions. As we can see, when running with transactions, the numbers are increased correctly 3 times, but the number is only increased by 1 when ran without transactions.
transactions-example.mov
With transactions
Without transactions