Skip to content

Commit 8a3f8ca

Browse files
authored
chore: update timeout and retry config (via synth) (#99)
1 parent 2b5946d commit 8a3f8ca

37 files changed

+1901
-1742
lines changed

.flake8

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ exclude =
2121
# Exclude generated code.
2222
**/proto/**
2323
**/gapic/**
24+
**/services/**
25+
**/types/**
2426
*_pb2.py
2527

2628
# Standard linting exemptions.

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
dist
1111
build
1212
eggs
13+
.eggs
1314
parts
1415
bin
1516
var
@@ -49,6 +50,7 @@ bigquery/docs/generated
4950
# Virtual environment
5051
env/
5152
coverage.xml
53+
sponge_log.xml
5254

5355
# System test environment variables.
5456
system_tests/local_test_setup

.kokoro/release.sh

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@
1313
# See the License for the specific language governing permissions and
1414
# limitations under the License.
1515

16-
#!/bin/bash
17-
1816
set -eo pipefail
1917

2018
# Start the releasetool reporter

MANIFEST.in

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,3 +21,6 @@ recursive-include google *.json *.proto
2121
recursive-include tests *
2222
global-exclude *.py[co]
2323
global-exclude __pycache__
24+
25+
# Exclude scripts for samples readmegen
26+
prune scripts/readme-gen

docs/conf.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -38,21 +38,18 @@
3838
"sphinx.ext.napoleon",
3939
"sphinx.ext.todo",
4040
"sphinx.ext.viewcode",
41+
"recommonmark",
4142
]
4243

4344
# autodoc/autosummary flags
4445
autoclass_content = "both"
45-
autodoc_default_flags = ["members"]
46+
autodoc_default_options = {"members": True}
4647
autosummary_generate = True
4748

4849

4950
# Add any paths that contain templates here, relative to this directory.
5051
templates_path = ["_templates"]
5152

52-
# Allow markdown includes (so releases.md can include CHANGLEOG.md)
53-
# http://www.sphinx-doc.org/en/master/markdown.html
54-
source_parsers = {".md": "recommonmark.parser.CommonMarkParser"}
55-
5653
# The suffix(es) of source filenames.
5754
# You can specify multiple suffix as a list of string:
5855
# source_suffix = ['.rst', '.md']

docs/index.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
.. include:: README.rst
22

3+
.. include:: multiprocessing.rst
4+
35
Usage Documentation
46
-------------------
57
.. toctree::

docs/multiprocessing.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.. note::
2+
3+
Because this client uses :mod:`grpcio` library, it is safe to
4+
share instances across threads. In multiprocessing scenarios, the best
5+
practice is to create client instances *after* the invocation of
6+
:func:`os.fork` by :class:`multiprocessing.Pool` or
7+
:class:`multiprocessing.Process`.

google/cloud/spanner_admin_database_v1/gapic/database_admin_client.py

Lines changed: 104 additions & 104 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,110 @@ def __init__(
232232
self._inner_api_calls = {}
233233

234234
# Service calls
235+
def list_databases(
236+
self,
237+
parent,
238+
page_size=None,
239+
retry=google.api_core.gapic_v1.method.DEFAULT,
240+
timeout=google.api_core.gapic_v1.method.DEFAULT,
241+
metadata=None,
242+
):
243+
"""
244+
Lists Cloud Spanner databases.
245+
246+
Example:
247+
>>> from google.cloud import spanner_admin_database_v1
248+
>>>
249+
>>> client = spanner_admin_database_v1.DatabaseAdminClient()
250+
>>>
251+
>>> parent = client.instance_path('[PROJECT]', '[INSTANCE]')
252+
>>>
253+
>>> # Iterate over all results
254+
>>> for element in client.list_databases(parent):
255+
... # process element
256+
... pass
257+
>>>
258+
>>>
259+
>>> # Alternatively:
260+
>>>
261+
>>> # Iterate over results one page at a time
262+
>>> for page in client.list_databases(parent).pages:
263+
... for element in page:
264+
... # process element
265+
... pass
266+
267+
Args:
268+
parent (str): Required. The instance whose databases should be listed. Values are
269+
of the form ``projects/<project>/instances/<instance>``.
270+
page_size (int): The maximum number of resources contained in the
271+
underlying API response. If page streaming is performed per-
272+
resource, this parameter does not affect the return value. If page
273+
streaming is performed per-page, this determines the maximum number
274+
of resources in a page.
275+
retry (Optional[google.api_core.retry.Retry]): A retry object used
276+
to retry requests. If ``None`` is specified, requests will
277+
be retried using a default configuration.
278+
timeout (Optional[float]): The amount of time, in seconds, to wait
279+
for the request to complete. Note that if ``retry`` is
280+
specified, the timeout applies to each individual attempt.
281+
metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata
282+
that is provided to the method.
283+
284+
Returns:
285+
A :class:`~google.api_core.page_iterator.PageIterator` instance.
286+
An iterable of :class:`~google.cloud.spanner_admin_database_v1.types.Database` instances.
287+
You can also iterate over the pages of the response
288+
using its `pages` property.
289+
290+
Raises:
291+
google.api_core.exceptions.GoogleAPICallError: If the request
292+
failed for any reason.
293+
google.api_core.exceptions.RetryError: If the request failed due
294+
to a retryable error and retry attempts failed.
295+
ValueError: If the parameters are invalid.
296+
"""
297+
# Wrap the transport method to add retry and timeout logic.
298+
if "list_databases" not in self._inner_api_calls:
299+
self._inner_api_calls[
300+
"list_databases"
301+
] = google.api_core.gapic_v1.method.wrap_method(
302+
self.transport.list_databases,
303+
default_retry=self._method_configs["ListDatabases"].retry,
304+
default_timeout=self._method_configs["ListDatabases"].timeout,
305+
client_info=self._client_info,
306+
)
307+
308+
request = spanner_database_admin_pb2.ListDatabasesRequest(
309+
parent=parent, page_size=page_size
310+
)
311+
if metadata is None:
312+
metadata = []
313+
metadata = list(metadata)
314+
try:
315+
routing_header = [("parent", parent)]
316+
except AttributeError:
317+
pass
318+
else:
319+
routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata(
320+
routing_header
321+
)
322+
metadata.append(routing_metadata)
323+
324+
iterator = google.api_core.page_iterator.GRPCIterator(
325+
client=None,
326+
method=functools.partial(
327+
self._inner_api_calls["list_databases"],
328+
retry=retry,
329+
timeout=timeout,
330+
metadata=metadata,
331+
),
332+
request=request,
333+
items_field="databases",
334+
request_token_field="page_token",
335+
response_token_field="next_page_token",
336+
)
337+
return iterator
338+
235339
def create_database(
236340
self,
237341
parent,
@@ -1817,107 +1921,3 @@ def list_backup_operations(
18171921
response_token_field="next_page_token",
18181922
)
18191923
return iterator
1820-
1821-
def list_databases(
1822-
self,
1823-
parent,
1824-
page_size=None,
1825-
retry=google.api_core.gapic_v1.method.DEFAULT,
1826-
timeout=google.api_core.gapic_v1.method.DEFAULT,
1827-
metadata=None,
1828-
):
1829-
"""
1830-
Lists Cloud Spanner databases.
1831-
1832-
Example:
1833-
>>> from google.cloud import spanner_admin_database_v1
1834-
>>>
1835-
>>> client = spanner_admin_database_v1.DatabaseAdminClient()
1836-
>>>
1837-
>>> parent = client.instance_path('[PROJECT]', '[INSTANCE]')
1838-
>>>
1839-
>>> # Iterate over all results
1840-
>>> for element in client.list_databases(parent):
1841-
... # process element
1842-
... pass
1843-
>>>
1844-
>>>
1845-
>>> # Alternatively:
1846-
>>>
1847-
>>> # Iterate over results one page at a time
1848-
>>> for page in client.list_databases(parent).pages:
1849-
... for element in page:
1850-
... # process element
1851-
... pass
1852-
1853-
Args:
1854-
parent (str): Required. The instance whose databases should be listed. Values are
1855-
of the form ``projects/<project>/instances/<instance>``.
1856-
page_size (int): The maximum number of resources contained in the
1857-
underlying API response. If page streaming is performed per-
1858-
resource, this parameter does not affect the return value. If page
1859-
streaming is performed per-page, this determines the maximum number
1860-
of resources in a page.
1861-
retry (Optional[google.api_core.retry.Retry]): A retry object used
1862-
to retry requests. If ``None`` is specified, requests will
1863-
be retried using a default configuration.
1864-
timeout (Optional[float]): The amount of time, in seconds, to wait
1865-
for the request to complete. Note that if ``retry`` is
1866-
specified, the timeout applies to each individual attempt.
1867-
metadata (Optional[Sequence[Tuple[str, str]]]): Additional metadata
1868-
that is provided to the method.
1869-
1870-
Returns:
1871-
A :class:`~google.api_core.page_iterator.PageIterator` instance.
1872-
An iterable of :class:`~google.cloud.spanner_admin_database_v1.types.Database` instances.
1873-
You can also iterate over the pages of the response
1874-
using its `pages` property.
1875-
1876-
Raises:
1877-
google.api_core.exceptions.GoogleAPICallError: If the request
1878-
failed for any reason.
1879-
google.api_core.exceptions.RetryError: If the request failed due
1880-
to a retryable error and retry attempts failed.
1881-
ValueError: If the parameters are invalid.
1882-
"""
1883-
# Wrap the transport method to add retry and timeout logic.
1884-
if "list_databases" not in self._inner_api_calls:
1885-
self._inner_api_calls[
1886-
"list_databases"
1887-
] = google.api_core.gapic_v1.method.wrap_method(
1888-
self.transport.list_databases,
1889-
default_retry=self._method_configs["ListDatabases"].retry,
1890-
default_timeout=self._method_configs["ListDatabases"].timeout,
1891-
client_info=self._client_info,
1892-
)
1893-
1894-
request = spanner_database_admin_pb2.ListDatabasesRequest(
1895-
parent=parent, page_size=page_size
1896-
)
1897-
if metadata is None:
1898-
metadata = []
1899-
metadata = list(metadata)
1900-
try:
1901-
routing_header = [("parent", parent)]
1902-
except AttributeError:
1903-
pass
1904-
else:
1905-
routing_metadata = google.api_core.gapic_v1.routing_header.to_grpc_metadata(
1906-
routing_header
1907-
)
1908-
metadata.append(routing_metadata)
1909-
1910-
iterator = google.api_core.page_iterator.GRPCIterator(
1911-
client=None,
1912-
method=functools.partial(
1913-
self._inner_api_calls["list_databases"],
1914-
retry=retry,
1915-
timeout=timeout,
1916-
metadata=metadata,
1917-
),
1918-
request=request,
1919-
items_field="databases",
1920-
request_token_field="page_token",
1921-
response_token_field="next_page_token",
1922-
)
1923-
return iterator

google/cloud/spanner_admin_database_v1/gapic/database_admin_client_config.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,13 +17,18 @@
1717
}
1818
},
1919
"methods": {
20+
"ListDatabases": {
21+
"timeout_millis": 3600000,
22+
"retry_codes_name": "idempotent",
23+
"retry_params_name": "default",
24+
},
2025
"CreateDatabase": {
2126
"timeout_millis": 3600000,
2227
"retry_codes_name": "non_idempotent",
2328
"retry_params_name": "default",
2429
},
2530
"GetDatabase": {
26-
"timeout_millis": 30000,
31+
"timeout_millis": 3600000,
2732
"retry_codes_name": "idempotent",
2833
"retry_params_name": "default",
2934
},
@@ -38,7 +43,7 @@
3843
"retry_params_name": "default",
3944
},
4045
"GetDatabaseDdl": {
41-
"timeout_millis": 30000,
46+
"timeout_millis": 3600000,
4247
"retry_codes_name": "idempotent",
4348
"retry_params_name": "default",
4449
},
@@ -63,12 +68,12 @@
6368
"retry_params_name": "default",
6469
},
6570
"GetBackup": {
66-
"timeout_millis": 600000,
71+
"timeout_millis": 3600000,
6772
"retry_codes_name": "idempotent",
6873
"retry_params_name": "default",
6974
},
7075
"UpdateBackup": {
71-
"timeout_millis": 600000,
76+
"timeout_millis": 3600000,
7277
"retry_codes_name": "non_idempotent",
7378
"retry_params_name": "default",
7479
},
@@ -78,7 +83,7 @@
7883
"retry_params_name": "default",
7984
},
8085
"ListBackups": {
81-
"timeout_millis": 600000,
86+
"timeout_millis": 3600000,
8287
"retry_codes_name": "idempotent",
8388
"retry_params_name": "default",
8489
},
@@ -88,17 +93,12 @@
8893
"retry_params_name": "default",
8994
},
9095
"ListDatabaseOperations": {
91-
"timeout_millis": 600000,
96+
"timeout_millis": 3600000,
9297
"retry_codes_name": "idempotent",
9398
"retry_params_name": "default",
9499
},
95100
"ListBackupOperations": {
96-
"timeout_millis": 600000,
97-
"retry_codes_name": "idempotent",
98-
"retry_params_name": "default",
99-
},
100-
"ListDatabases": {
101-
"timeout_millis": 60000,
101+
"timeout_millis": 3600000,
102102
"retry_codes_name": "idempotent",
103103
"retry_params_name": "default",
104104
},

0 commit comments

Comments
 (0)