comparison tests/test-batching.py @ 47873:c424ff4807e6

wireprotov1peer: update all rpcs to use the new batchable scheme If desired, we could keep the future class and the function that upgrades an old style rpc instead of a new style, for extensions. Differential Revision: https://phab.mercurial-scm.org/D11212
author Valentin Gatien-Baron <valentin.gatienbaron@gmail.com>
date Tue, 24 Aug 2021 17:27:16 +0200
parents 05dd091dfa6a
children 6000f5b25c9b
comparison
equal deleted inserted replaced
47872:cdad6560e832 47873:c424ff4807e6
212 ( 212 (
213 b'two', 213 b'two',
214 mangle(two), 214 mangle(two),
215 ), 215 ),
216 ] 216 ]
217 encoded_res_future = wireprotov1peer.future() 217 return encoded_args, unmangle
218 yield encoded_args, encoded_res_future
219 yield unmangle(encoded_res_future.value)
220 218
221 @wireprotov1peer.batchable 219 @wireprotov1peer.batchable
222 def bar(self, b, a): 220 def bar(self, b, a):
223 encresref = wireprotov1peer.future() 221 return [
224 yield [
225 ( 222 (
226 b'b', 223 b'b',
227 mangle(b), 224 mangle(b),
228 ), 225 ),
229 ( 226 (
230 b'a', 227 b'a',
231 mangle(a), 228 mangle(a),
232 ), 229 ),
233 ], encresref 230 ], unmangle
234 yield unmangle(encresref.value)
235 231
236 # greet is coded directly. It therefore does not support batching. If it 232 # greet is coded directly. It therefore does not support batching. If it
237 # does appear in a batch, the batch is split around greet, and the call to 233 # does appear in a batch, the batch is split around greet, and the call to
238 # greet is done in its own roundtrip. 234 # greet is done in its own roundtrip.
239 def greet(self, name=None): 235 def greet(self, name=None):