@@ -45,7 +45,7 @@ def _exception_class_for_grpc_status_name(name):
45
45
return exceptions .exception_class_for_grpc_status (getattr (grpc .StatusCode , name ))
46
46
47
47
48
- def _retry_from_retry_config (retry_params , retry_codes ):
48
+ def _retry_from_retry_config (retry_params , retry_codes , retry_impl = retry . Retry ):
49
49
"""Creates a Retry object given a gapic retry configuration.
50
50
51
51
Args:
@@ -70,7 +70,7 @@ def _retry_from_retry_config(retry_params, retry_codes):
70
70
exception_classes = [
71
71
_exception_class_for_grpc_status_name (code ) for code in retry_codes
72
72
]
73
- return retry . Retry (
73
+ return retry_impl (
74
74
retry .if_exception_type (* exception_classes ),
75
75
initial = (retry_params ["initial_retry_delay_millis" ] / _MILLIS_PER_SECOND ),
76
76
maximum = (retry_params ["max_retry_delay_millis" ] / _MILLIS_PER_SECOND ),
@@ -110,7 +110,7 @@ def _timeout_from_retry_config(retry_params):
110
110
MethodConfig = collections .namedtuple ("MethodConfig" , ["retry" , "timeout" ])
111
111
112
112
113
- def parse_method_configs (interface_config ):
113
+ def parse_method_configs (interface_config , retry_impl = retry . Retry ):
114
114
"""Creates default retry and timeout objects for each method in a gapic
115
115
interface config.
116
116
@@ -120,6 +120,8 @@ def parse_method_configs(interface_config):
120
120
an interface named ``google.example.v1.ExampleService`` you would
121
121
pass in just that interface's configuration, for example
122
122
``gapic_config['interfaces']['google.example.v1.ExampleService']``.
123
+ retry_impl (Callable): The constructor that creates a retry decorator
124
+ that will be applied to the method based on method configs.
123
125
124
126
Returns:
125
127
Mapping[str, MethodConfig]: A mapping of RPC method names to their
@@ -151,7 +153,7 @@ def parse_method_configs(interface_config):
151
153
if retry_params_name is not None :
152
154
retry_params = retry_params_map [retry_params_name ]
153
155
retry_ = _retry_from_retry_config (
154
- retry_params , retry_codes_map [method_params ["retry_codes_name" ]]
156
+ retry_params , retry_codes_map [method_params ["retry_codes_name" ]], retry_impl
155
157
)
156
158
timeout_ = _timeout_from_retry_config (retry_params )
157
159
0 commit comments