-
Notifications
You must be signed in to change notification settings - Fork 600
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
refactor(batch): return Err when polling finished executor #1544
Conversation
Maintaining such code is hard. You will never know whether there will be new executors in the future, and how they will act. https://doc.rust-lang.org/stable/std/iter/struct.Fuse.html One good approach is to have something like |
Also by convention, it would be better to always return Ok(None) instead of error. |
Codecov Report
@@ Coverage Diff @@
## main #1544 +/- ##
============================================
- Coverage 69.73% 69.71% -0.03%
Complexity 2766 2766
============================================
Files 1041 1042 +1
Lines 91493 91629 +136
Branches 1790 1790
============================================
+ Hits 63799 63875 +76
- Misses 26803 26863 +60
Partials 891 891
Flags with carried forward coverage won't be shown. Click here to find out more.
📣 Codecov can now indicate which changes are the most critical in Pull Requests. Learn more |
I also find that returning |
844704f
to
112fee1
Compare
I use the method explained by @skyzh to wrap the original executor. I also add an example use of the wrapper on
Any suggestions? I will work on all other executors if this approach is desired. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Generally LGTM.
The renaming of FilterExecutor
-> FilterExecutorInner
seems not necessary. We can simply refactor all new_boxed_executor
to return fused executors.
We can then add a fuse
function on executor trait (or have a new trait that implements for all executors), and make all new_boxed_executor
to return Box::new(original_executor.fuse())
.
IIRC, there was one bug where one executor polls its child and gets I don't argue that the bug can only be exposed by returning I feel the convention of returning One argument against using |
I would +1 for return Ok(None). In some parts of our program, there might be some logic that calls |
Maybe we can work on this? #1190 |
Refactoring all of these executors with futures_async_stream would solve issue #1174 in addition to issue #890. And that sounds great. But I don't consider this pr is in conflict with this refactoring. Because this pr is a refinement of the current implementation of executors.
This pr is based on the assumption that after a batch executor emits an In the following example, the loop will terminate after it receives an I've checked the use of the batch executor, but I'm not sure if I'm missing something. Can you provide a code example (if there is any) where the implementation of this pr would break the behavior of the program? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. Keep refactoring other executors, and we can get this merged. Hope this can be done today, as we have a big renaming tomorrow.
What's changed and what's your intention?
When an executor is finished(i.e. calls to
next()
returnsOk(None)
), subsequent call tonext
will now returnErr
.FuseExecutor
is a wrapper on an original executor, it tracks the state of the underlying executor. Once the underlying executor returnsOk(None)
,FuseExecutor
will returnErr
for all subsequent calls.Describe clearly one logical change and avoid lazy messages (optional)
Describe any limitations of the current code (optional)
Checklist
Refer to a related PR or issue link (optional)
this pr fix #890