GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — feat: add new dispatch compose by metcoder95 · Pull Request #2826 · nodejs/undici Conversation
| ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Next, time to fight with tests and adapt it |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I think just making it available with docs is sufficient here and then we can apply it in next with a revision of my PR.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Missing docs and tests
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
I would also like us to have some kind of benchmark to this pattern to make sure it doesn't add too much overhead. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Co-authored-by: Matteo Collina <[email protected]>
|
@ronag, did the Proxy worked for you? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
All tests passed. So I think so? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Well, that's because we I've not pushed the tests for the compose feature; still in my machine and constantly failing, on top I forgot to add the extra dispatcher on the constructor for the Proxy. But its fine, I just wanted to be sure I had the whole picture. Most likely I'll put back the Agent where it was, and copy/paste and adapt a new copy of the Agent proxy to take into account the new dispatcher arg |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@ ## main #2826 +/- ## ========================================== - Coverage 93.68% 93.48% -0.20% ========================================== Files 87 89 +2 Lines 23973 24102 +129 ========================================== + Hits 22458 22531 +73 - Misses 1515 1571 +56 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| const client = new Client("http://example.com"); | ||
|
|
||
| client.compose(proxy("http://proxy.com")); |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
| const client = new Client("http://example.com"); | |
| client.compose(proxy("http://proxy.com")); | |
| const client = new Client("http://example.com").compose(proxy("http://proxy.com")); |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| const client = new Client("http://example.com"); | ||
|
|
||
| client.compose(redirect({ maxRedirections: 3, throwOnMaxRedirects: true })); |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
| const client = new Client("http://example.com"); | |
| client.compose(redirect({ maxRedirections: 3, throwOnMaxRedirects: true })); | |
| const client = new Client("http://example.com").compose(redirect({ maxRedirections: 3, throwOnMaxRedirects: true })); |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| const client = new Client("http://example.com"); | ||
|
|
||
| client.compose( | ||
| retry({ | ||
| maxRetries: 3, | ||
| minTimeout: 1000, | ||
| maxTimeout: 10000, | ||
| timeoutFactor: 2, | ||
| retryAfter: true, | ||
| }) | ||
| ); |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
| const client = new Client("http://example.com"); | |
| client.compose( | |
| retry({ | |
| maxRetries: 3, | |
| minTimeout: 1000, | |
| maxTimeout: 10000, | |
| timeoutFactor: 2, | |
| retryAfter: true, | |
| }) | |
| ); | |
| const client = new Client("http://example.com").compose( | |
| retry({ | |
| maxRetries: 3, | |
| minTimeout: 1000, | |
| maxTimeout: 10000, | |
| timeoutFactor: 2, | |
| retryAfter: true, | |
| }) | |
| ); |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| const ProxyAgent = require('../dispatcher/proxy-agent') | ||
| const DispatcherBase = require('../dispatcher/dispatcher-base') | ||
|
|
||
| class ProxyInterceptor extends DispatcherBase { |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Please integrate this inside the ProxyAgent. We shouldn't have special classes for these.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I think this should extend Dispatcher, not DispatcherBase.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Please integrate this inside the ProxyAgent. We shouldn't have special classes for these.
Sure, let me double-check this part as I'm not totally confident about it, I'd try to first assess if the chain of dispatcher works as expected before trying to port it to the ProxyAgent
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| const Dispatcher = require('../dispatcher/dispatcher-base') | ||
| const RedirectHandler = require('../handler/RedirectHandler') | ||
|
|
||
| class RedirectDispatcher extends Dispatcher { |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
This class is useful as its own export.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
We can add it as a RedirectAgent
Sorry, something went wrong.
There was an error while loading. Please reload this page.
| @@ -0,0 +1,68 @@ | |||
| # Interceptors | |||
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Generically I don't think we need a special page for the interceptors. They are more confusing than anything else. Let's only have Dispatchers.
Having the use specify (dispatcher) => new MyDispatcher(dispatcher, myOpts) is not a problem for most devs. These helpers only add noise.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
|
||
| const EventEmitter = require('node:events') | ||
|
|
||
| const kDispatcherVersion = Symbol.for('undici.dispatcher.version') |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Is this the same simbol we use for the global? I think we should use the same.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I slightly disagree with @mcollina. I don't see any point in exposing the dispatcher classes themselves (why would you extend them)? Rather I would prefer exposing curry-able factory methods. That also makes the distinction between composable and non composable dispatcher clearer.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
I pushed the change to put both options over the table and chat about which one we would like to follow. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
It doesn't necessarily break it if the interceptor just passed a client factory that return the outer dispatcher? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Right, that's true; but also we use the |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
We can also just skip making it an interceptor. I'm fine with that. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Dropped the |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
lgtm
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.