@@ -147,7 +147,11 @@ class BidiRpc(object):
147
147
148
148
initial_request = example_pb2.StreamingRpcRequest(
149
149
setting='example')
150
- rpc = BidiRpc(stub.StreamingRpc, initial_request=initial_request)
150
+ rpc = BidiRpc(
151
+ stub.StreamingRpc,
152
+ initial_request=initial_request,
153
+ metadata=[('name', 'value')]
154
+ )
151
155
152
156
rpc.open()
153
157
@@ -165,14 +169,14 @@ class BidiRpc(object):
165
169
Callable[None, protobuf.Message]]): The initial request to
166
170
yield. This is useful if an initial request is needed to start the
167
171
stream.
168
- rpc_metadata Sequence[Tuple(str, str)]: RPC metadata to include in
172
+ metadata ( Sequence[Tuple(str, str)]) : RPC metadata to include in
169
173
the request.
170
174
"""
171
175
172
- def __init__ (self , start_rpc , initial_request = None , rpc_metadata = None ):
176
+ def __init__ (self , start_rpc , initial_request = None , metadata = None ):
173
177
self ._start_rpc = start_rpc
174
178
self ._initial_request = initial_request
175
- self ._rpc_metadata = rpc_metadata
179
+ self ._rpc_metadata = metadata
176
180
self ._request_queue = queue .Queue ()
177
181
self ._request_generator = None
178
182
self ._is_active = False
@@ -291,10 +295,14 @@ def should_recover(exc):
291
295
initial_request = example_pb2.StreamingRpcRequest(
292
296
setting='example')
293
297
294
- rpc = ResumeableBidiRpc(
298
+ metadata = [('header_name', 'value')]
299
+
300
+ rpc = ResumableBidiRpc(
295
301
stub.StreamingRpc,
302
+ should_recover=should_recover,
296
303
initial_request=initial_request,
297
- should_recover=should_recover)
304
+ metadata=metadata
305
+ )
298
306
299
307
rpc.open()
300
308
@@ -313,13 +321,12 @@ def should_recover(exc):
313
321
should_recover (Callable[[Exception], bool]): A function that returns
314
322
True if th
8000
e stream should be recovered. This will be called
315
323
whenever an error is encountered on the stream.
316
- def _rpc_metadata(self):
317
- rpc_metadata Sequence[Tuple(str, str)]: RPC metadata to include in
324
+ metadata Sequence[Tuple(str, str)]: RPC metadata to include in
318
325
the request.
319
326
"""
320
327
321
- def __init__ (self , start_rpc , should_recover , initial_request = None , rpc_metadata = None ):
322
- super (ResumableBidiRpc , self ).__init__ (start_rpc , initial_request , rpc_metadata )
328
+ def __init__ (self , start_rpc , should_recover , initial_request = None , metadata = None ):
329
+ super (ResumableBidiRpc , self ).__init__ (start_rpc , initial_request , metadata )
323
330
self ._should_recover = should_recover
324
331
self ._operational_lock = threading .RLock ()
325
332
self ._finalized = False
0 commit comments