@@ -94,16 +94,17 @@ class _GapicCallable(object):
94
94
timeout (google.api_core.timeout.Timeout): The default timeout
95
95
for the callable. If ``None``, this callable will not specify
96
96
a timeout argument to the low-level RPC method by default.
97
- user_agent_metadata (Tuple[str, str]): The user agent metadata key and
98
- value to provide to the RPC method. If ``None``, no additional
99
- metadata will be passed to the RPC method.
97
+ metadata (Sequence[Tuple[str, str]]): Additional metadata that is
98
+ provided to the RPC method on every invocation. This is merged with
99
+ any metadata specified during invocation. If ``None``, no
100
+ additional metadata will be passed to the RPC method.
100
101
"""
101
102
102
- def __init__ (self , target , retry , timeout , user_agent_metadata = None ):
103
+ def __init__ (self , target , retry , timeout , metadata = None ):
103
104
self ._target = target
104
105
self ._retry = retry
105
106
self ._timeout = timeout
106
- self ._user_agent_metadata = user_agent_metadata
107
+ self ._metadata = metadata
107
108
108
109
def __call__ (self , * args , ** kwargs ):
109
110
"""Invoke the low-level RPC with retry, timeout, and metadata."""
@@ -126,9 +127,9 @@ def __call__(self, *args, **kwargs):
126
127
wrapped_func = _apply_decorators (self ._target , [retry , timeout_ ])
127
128
128
129
# Add the user agent metadata to the call.
129
- if self ._user_agent_metadata is not None :
130
- metadata = kwargs .get ('metadata' , [])
131
- metadata .append (self ._user_agent_metadata )
130
+ if self ._metadata is not None :
131
+ metadata = list ( kwargs .get ('metadata' , []) )
132
+ metadata .extend (self ._metadata )
132
133
kwargs ['metadata' ] = metadata
133
134
134
135
return wrapped_func (* args , ** kwargs )
@@ -219,11 +220,11 @@ def get_topic(name, timeout=None):
219
220
func = grpc_helpers .wrap_errors (func )
220
221
221
222
if client_info is not None :
222
- user_agent_metadata = client_info .to_grpc_metadata ()
223
+ user_agent_metadata = [ client_info .to_grpc_metadata ()]
223
224
else :
224
225
user_agent_metadata = None
225
226
226
227
return general_helpers .wraps (func )(
227
228
_GapicCallable (
228
229
func , default_retry , default_timeout ,
229
- user_agent_metadata = user_agent_metadata ))
230
+ metadata = user_agent_metadata ))
0 commit comments