Skip to content
Snippets Groups Projects
  • Gregory Szorc's avatar
    4c706037
    wireproto: overhaul iterating batcher code (API) · 4c706037
    Gregory Szorc authored
    The remote batching code is difficult to read. Let's improve it.
    
    As part of the refactor, the future returned by method calls on
    batchiter() instances is now populated. However, you still need to
    consume the results() generator for the future to be set.  But at
    least now we can stuff the future somewhere and not have to worry
    about aligning method call order with result order since you can
    use a future to hold the result.
    
    Also as part of the change, we now verify that @batchable generators
    yield exactly 2 values. In other words, we enforce their API.
    
    The non-iter batcher has been unused since b6e71f8af5b8. And to my
    surprise we had no explicit unit test coverage of it! test-batching.py
    has been overhauled to use the iterating batcher.
    
    Since the iterating batcher doesn't allow non-batchable method
    calls nor local calls, tests have been updated to reflect reality.
    The iterating batcher has been used for multiple releases apparently
    without major issue. So this shouldn't cause alarm.
    
    .. api::
    
       @peer.batchable functions must now yield exactly 2 values
    
    Differential Revision: https://phab.mercurial-scm.org/D319
    4c706037
    History
    wireproto: overhaul iterating batcher code (API)
    Gregory Szorc authored
    The remote batching code is difficult to read. Let's improve it.
    
    As part of the refactor, the future returned by method calls on
    batchiter() instances is now populated. However, you still need to
    consume the results() generator for the future to be set.  But at
    least now we can stuff the future somewhere and not have to worry
    about aligning method call order with result order since you can
    use a future to hold the result.
    
    Also as part of the change, we now verify that @batchable generators
    yield exactly 2 values. In other words, we enforce their API.
    
    The non-iter batcher has been unused since b6e71f8af5b8. And to my
    surprise we had no explicit unit test coverage of it! test-batching.py
    has been overhauled to use the iterating batcher.
    
    Since the iterating batcher doesn't allow non-batchable method
    calls nor local calls, tests have been updated to reflect reality.
    The iterating batcher has been used for multiple releases apparently
    without major issue. So this shouldn't cause alarm.
    
    .. api::
    
       @peer.batchable functions must now yield exactly 2 values
    
    Differential Revision: https://phab.mercurial-scm.org/D319