googleapis / googleapis/google-cloud-python

Add wrap logic directly to the property methods for callables for long running operations

未关闭
#15,037 2 条评论 0 个 reaction 已指派 1 人 已被 @ohmayr 认领 在 GitHub 查看
priority: p3 type: feature request
主要语言
Python
星标
5.4k
派生
1.8k
平均合并
3 天 4 小时
30 天内合并 PR
122

描述

Instead of implementing `_prep_wrapped_messages` in the base class and overriding it in the async classes, we should wrap the logic directly within the property callable methods and get rid of this method (both from the base class and the subclasses).

What we have now:

```python3
@property
def get_operation(
self,
) -> Callable[
[operations_pb2.GetOperationRequest],
Coroutine[Any, Any, operations_pb2.Operation],
]:
return self._get_operation
```

Instead we could do something like:
```python3
@property
def get_operation(
self,
) -> Callable[
[operations_pb2.GetOperationRequest],
Coroutine[Any, Any, operations_pb2.Operation],
]:
return gapic_v1.method_async.wrap_method(
self.list_operations,
default_retry=retries_async.AsyncRetry(
initial=0.5,
maximum=10.0,
multiplier=2.0,
predicate=retries_async.if_exception_type(
core_exceptions.ServiceUnavailable,
),
deadline=10.0,
),
default_timeout=10.0,
client_info=self.client_info,
),
```

贡献指南

打开贡献指南

评估

这个 Issue 还没有评估数据。

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。