8000 Improvements to the Transaction API by hiranya911 · Pull Request #57 · firebase/firebase-admin-python · GitHub
[go: up one dir, main page]

Skip to content

Improvements to the Transaction API #57

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

Merged
merged 5 commits into from
Aug 14, 2017
Merged

Improvements to the Transaction API #57

merged 5 commits into from
Aug 14, 2017

Conversation

hiranya911
Copy link
Contributor

Follow up to #54. Implements #56.

  • Returning the updated value from transaction() method.
  • Updated API docs.

rockwotj
rockwotj previously approved these changes Aug 12, 2017

Args:
transaction_update: function that takes in current database data as a parameter.
transaction_update: A function which will be passed tbe current data stored at this
Copy link
Contributor

Choose a reason for hiding this comment

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

s/tbe/the

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

@rockwotj rockwotj dismissed their stale review August 12, 2017 01:27

Didn't mean to do that

value of this reference into a new value. If another client writes to this location before
the new value is successfully saved, the update function is called again with the new
current value, and the write will be retried. In case of repeated failures, this method
will retry the transaction up to 25 times before giving up and raising a TransactionError.

Choose a reason for hiding this comment

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

Do we want to make this number configurable?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think that's reasonable. I've created #58 to implement it. Since this requires an API review, I'll defer it to a future development cycle.

while tries < _TRANSACTION_MAX_RETRIES:
success, etag, snapshot = self._update_with_etag(val, etag)
new_data = transaction_update(data)
success, etag, data = self._update_with_etag(new_data, etag)

Choose a reason for hiding this comment

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

Are we using the etag?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, in the next iteration of the loop etag gets passed to the _update_with_etag() call.

return False
return new_data
tries += 1
raise TransactionError('Transaction aborted after failed retries.')

Choose a reason for hiding this comment

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

Should we add the number of retries attempted to this error?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Lets report that at #58 to be fixed in the future. We are trying to get a release build out at the moment.

@hiranya911 hiranya911 merged commit afe78f0 into master Aug 14, 2017
@hiranya911 hiranya911 deleted the hkj-txn-api branch August 14, 2017 20:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants
0