-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Add support for 'TransactionOptions' #4335
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
Add support for 'TransactionOptions' #4335
Conversation
dhermes
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@chemelnucfin Thanks for the work but it seems this effort is futile until support for TransactionOptions is in the gapic-google-cloud-datastore-v1 library (since the underlying GAX / proto-over-HTTP clients will never send the right payload).
That requires @lukesneeringer (or someone on his team) to regenerate the library.
| :type previous_transaction: `bytes` | ||
| :param previous_transaction: The transaction identifier of the transaction | ||
| being retried. | ||
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| ReadWrite. In the case of ReadWrite an optional parameter allows the | ||
| previous transaction id to be stored. | ||
| :type readonly: `boolean` |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| """ | ||
|
|
||
| class ReadWrite(object): |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| from google.cloud.datastore.batch import Batch | ||
|
|
||
|
|
||
| class TransactionOptions(object): |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| self._id = None | ||
|
|
||
| def put(self, entity): | ||
| """Remember an entity's state to be saved during :meth:`commit`. |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| """Remember an entity's state to be saved during :meth:`commit`. | ||
| .. note:: | ||
| Any existing properties for the entity will be replaced by those |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| if isinstance(self.options.mode, self.options.ReadWrite): | ||
| super(Transaction, self).put(entity) | ||
| else: | ||
| raise RuntimeError("Transaction is read only") |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| import mock | ||
| from google.cloud.datastore.transaction import TransactionOptions | ||
|
|
||
| class TestTransactionOptions(unittest.TestCase): |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
| import unittest | ||
|
|
||
| import mock | ||
| from google.cloud.datastore.transaction import TransactionOptions |
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
This comment was marked as spam.
This comment was marked as spam.
Sorry, something went wrong.
|
Thank you for your comments. |
IMO it's not worth working on this until you can actually send the payload to the live server, so I would wait. |
I am happy to do that as soon as I get in to the office. |
|
Auto-gen updated. In theory, this should now work against the live service (and we should test to ensure that). |
|
So there's good news and bad news. 👍 The good news is that everyone that needs to sign a CLA (the pull request submitter and all commit authors) have done so. Everything is all good there. 😕 The bad news is that it appears that one or more commits were authored by someone other than the pull request submitter. We need to confirm that all authors are ok with their commits being contributed to this project. Please have them confirm that here in the pull request. Note to project maintainer: This is a terminal state, meaning the |
8b5a48b to
cf97b76
Compare
|
See #4357 |
Uses #4348 as a base.
Please look it over and feel free to critique.
Also let me know what I'm missing.
Closes #4278.