-
Notifications
You must be signed in to change notification settings - Fork 981
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
Add support for a new ParallelManager#execute
method.
#1584
Conversation
The new interface passes the parallel block with all the requests to the ParallelManager, instead of running it beforehand. This allows for better, stateless ParallelManager implementations. Fixes #1583
f55e7f5
to
67dea51
Compare
If you want to add tests, you could use |
@iMacTia can you carefully review socketry/async-http-faraday#45 to ensure I've implemented it correctly. It appears to be working. cc @olleolleolle :) |
Thanks for working on this, it's awesome :) |
I actually tried this locally because we already use When I get more time I'll give it another go 👍 thanks for the suggestion |
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.
Lovely!
def call(env) | ||
# NB: you can call `in_parallel?` here to check if the current request | ||
# is part of a parallel batch. Useful if you need to collect all requests | ||
# into the ParallelManager before running them. |
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.
This context-giving comment is gold.
end | ||
end | ||
``` | ||
|
||
Compare to the finished example [em-synchrony](https://github.com/lostisland/faraday-em_synchrony/blob/main/lib/faraday/adapter/em_synchrony.rb) | ||
### A note on the old, deprecated interface |
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.
Oh, and so good with this note!
# Execute is the new method that is responsible for executing the block. | ||
@parallel_manager.execute(&block) | ||
else | ||
# TODO: Old behaviour, deprecate and remove in 3.0 |
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.
(Very kind not to emit deprecation warnings, here!)
Co-authored-by: Olle Jonsson <[email protected]>
Description
The new interface passes the parallel block with all the requests to the ParallelManager, instead of running it beforehand.
This allows for better, stateless ParallelManager implementations.
Fixes #1583
Todos
List any remaining work that needs to be done, i.e: