Skip to content
This repository was archived by the owner on Mar 2, 2026. It is now read-only.

feat: add retry/timeout to manual surface#222

Merged
tseaver merged 41 commits into
masterfrom
221-retry-timeout
Oct 21, 2020
Merged

feat: add retry/timeout to manual surface#222
tseaver merged 41 commits into
masterfrom
221-retry-timeout

Conversation

@tseaver

@tseaver tseaver commented Oct 13, 2020

Copy link
Copy Markdown
Contributor

Base Classes

  • base_client.BaseClient.collections (signature only)
  • base_client.BaseClient.get_all (signature only)
  • base_collection.BaseCollectionReference.add (signature only)
  • base_collection.BaseCollectionReference.get (signature only)
  • base_collection.BaseCollectionReference.list_documents (signature only)
  • base_collection.BaseCollectionReference.stream (signature only)
  • base_document.BaseDocumentReference.collections (signature only)
  • base_document.BaseDocumentReference.create (signature only)
  • base_document.BaseDocumentReference.delete (signature only)
  • base_document.BaseDocumentReference.get (signature only)
  • base_document.BaseDocumentReference.set (signature only)
  • base_document.BaseDocumentReference.update (signature only)
  • base_query.BaseCollectionGroup.get_partitions (signature only)
  • base_query.BaseQuery.get (signature only)
  • base_query.BaseQuery.stream (signature only)
  • base_transaction.BaseTransaction.get (signature only)
  • base_transaction.BaseTransaction.get_all (signature only)

Synchronous

  • batch.Batch.commit
  • client.Client.collections
  • client.Client.get_all
  • collection.Collection.add
  • collection.Collection.get
  • collection.Collection.list_documents
  • collection.Collection.stream
  • document.Document.collections
  • document.Document.create
  • document.Document.delete
  • document.Document.get
  • document.Document.set
  • document.Document.update
  • query.CollectionGroup.get_partitions
  • query.Query.get
  • query.Query.stream
  • transaction.Transaction.get
  • transaction.Transaction.get_all

Asynchronous

  • async_batch.AsyncBatch.commit
  • async_client.AsyncClient.collections
  • async_client.AsyncClient.get_all
  • async_collection.AsyncCollection.add
  • async_collection.AsyncCollection.get
  • async_collection.AsyncCollection.list_documents
  • async_collection.AsyncCollection.stream
  • async_document.AsyncDocument.collections
  • async_document.AsyncDocument.create
  • async_document.AsyncDocument.delete
  • async_document.AsyncDocument.get
  • async_document.AsyncDocument.set
  • async_document.AsyncDocument.update
  • async_query.AsyncCollectionGroup.get_partitions
  • async_query.AsyncQuery.get
  • async_query.AsyncQuery.stream
  • async_transaction.AsyncTransaction.get
  • async_transaction.AsyncTransaction.get_all

Unsure

  • base_collection.BaseCollection.on_snapshot (signature only)
  • base_document.BaseDocumentRef.on_snapshot (signature only)
  • base_query.BaseQuery.on_snapshot (signature only)
  • collection.Collection.on_snapshot
  • document.Document.on_snapshot
  • query.Query.on_snapshot
  • watch.Watch.__init__
  • watch.Watch.for_document
  • watch.Watch.for_query

Closes #221

@google-cla google-cla Bot added the cla: yes This human has signed the Contributor License Agreement. label Oct 13, 2020
Methods include:

- 'create'
- 'set'
- 'update'
- 'delete'
- 'get'
- 'collections'

Toward #221
@tseaver
tseaver marked this pull request as ready for review October 14, 2020 20:12
@tseaver
tseaver requested review from a team and chrisrossi October 14, 2020 20:12
@tseaver

tseaver commented Oct 14, 2020

Copy link
Copy Markdown
Contributor Author

Note to reviewers: commit-by-commit is likely the most fruitful approach.

Updated: I just reviewed it as a whole, and think it is easier than following the commit-by-commit path.

@tseaver tseaver left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Comments on commit-by-commit review reflecting later changes as the PR evolved.

Comment thread google/cloud/firestore_v1/client.py Outdated
if timeout is not None:
kwargs["timeout"] = timeout

return kwargs

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Later commits factor this method out into _helpers.make_retry_timeout_kwargs.

retry=retry,
timeout=timeout,
metadata=client._rpc_metadata,
)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

40fae96 removes most of the redundancy in the tests for Client.get_all.

Comment thread tests/unit/v1/test_client.py Outdated
timeout=timeout,
metadata=client._rpc_metadata,
)

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

bad75e1 factors out the redundancy in the tests for Client.collections.

Comment thread google/cloud/firestore_v1/batch.py Outdated
kwargs["retry"] = retry

if timeout is not None:
kwargs["timeout"] = timeout

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Since factored out to use _helpers.make_retry_timeout_kwargs.

Comment thread tests/unit/v1/test_batch.py Outdated
kwargs["retry"] = retry

if timeout is not None:
kwargs["timeout"] = timeout

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Likewise, later commits update to use the helper here.

Comment thread tests/unit/v1/test_transaction.py Outdated
kwargs["retry"] = retry

if timeout is not None:
kwargs["timeout"] = timeout

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Factored out later to use the helper.

Comment thread tests/unit/v1/test_client.py Outdated
kwargs["retry"] = retry

if timeout is not None:
kwargs["timeout"] = timeout

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Factored out later to use the helper.

Comment thread tests/unit/v1/test_async_client.py Outdated
kwargs["retry"] = retry

if timeout is not None:
kwargs["timeout"] = timeout

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Factored out later to use the helper.

for i in iterator.collection_ids:
yield self.collection(i)
if iterator.next_page_token:
next_request = request.cpoy()

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Typo fixed in 9b4707a

Comment thread google/cloud/firestore_v1/document.py Outdated
for i in iterator.collection_ids:
yield self.collection(i)
if iterator.next_page_token:
next_request = request.cpoy()

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Typo fixed in 1acbde3

Comment thread google/cloud/firestore_v1/query.py
firestore_api.list_collection_ids.return_value = iterator

collections = [c async for c in client.collections()]
collections = [c async for c in client.collections(**kwargs)]

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

just confirming, you have added these changes to a few tests to get complete coverage? The changes of this PR shouldn't result in any required changes to users correct?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Right. See test_collections and test_collections_w_retry_timeout below.

@tseaver tseaver added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Oct 21, 2020
@yoshi-kokoro yoshi-kokoro removed the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Oct 21, 2020
@tseaver
tseaver merged commit db5f286 into master Oct 21, 2020
@tseaver
tseaver deleted the 221-retry-timeout branch October 21, 2020 21:22
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

cla: yes This human has signed the Contributor License Agreement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Expose retry, timeout parameters in manual surface

3 participants