@@ -94,16 +94,17 @@ class _GapicCallable(object):
9494 timeout (google.api_core.timeout.Timeout): The default timeout
9595 for the callable. If ``None``, this callable will not specify
9696 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.
100101 """
101102
102- def __init__ (self , target , retry , timeout , user_agent_metadata = None ):
103+ def __init__ (self , target , retry , timeout , metadata = None ):
103104 self ._target = target
104105 self ._retry = retry
105106 self ._timeout = timeout
106- self ._user_agent_metadata = user_agent_metadata
107+ self ._metadata = metadata
107108
108109 def __call__ (self , * args , ** kwargs ):
109110 """Invoke the low-level RPC with retry, timeout, and metadata."""
@@ -126,9 +127,9 @@ def __call__(self, *args, **kwargs):
126127 wrapped_func = _apply_decorators (self ._target , [retry , timeout_ ])
127128
128129 # 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 )
132133 kwargs ['metadata' ] = metadata
133134
134135 return wrapped_func (* args , ** kwargs )
@@ -219,11 +220,11 @@ def get_topic(name, timeout=None):
219220 func = grpc_helpers .wrap_errors (func )
220221
221222 if client_info is not None :
222- user_agent_metadata = client_info .to_grpc_metadata ()
223+ user_agent_metadata = [ client_info .to_grpc_metadata ()]
223224 else :
224225 user_agent_metadata = None
225226
226227 return general_helpers .wraps (func )(
227228 _GapicCallable (
228229 func , default_retry , default_timeout ,
229- user_agent_metadata = user_agent_metadata ))
230+ metadata = user_agent_metadata ))
0 commit comments