Skip to content
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

fix: interceptor back-pressure #3374

Closed
wants to merge 5 commits into from
Closed

fix: interceptor back-pressure #3374

wants to merge 5 commits into from

Conversation

ronag
Copy link
Member

@ronag ronag commented Jun 25, 2024

Tries to resolve the back-pressure issue. Downside is that it gives up on forwarding dispatcher events.

Refs: #3376

@ronag ronag force-pushed the ondrain branch 2 times, most recently from 6950c88 to 4e3cfc5 Compare June 25, 2024 19:22
@ronag ronag marked this pull request as draft June 25, 2024 19:24
@ronag
Copy link
Member Author

ronag commented Jun 25, 2024

Not working yet, just a POC

@@ -517,6 +529,11 @@ async function connect (client) {

function emitDrain (client) {
client[kNeedDrain] = 0

for (const callback of client[kDrainQueue].splice(0)) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does it differs from subscribing to dispatcher.on('drain')?

Sure, it is integrated as first-class-citizen, but it kind overlaps with the drain event isn't it?

If the retry interceptor wants to implement backpressure, it can handle the last value returned from dispatch, and decide what to do on the next attempt, e.g. waiting for the event or trying once more, isn't it?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

'drain' applies globally while onDrain applies to this specific request, e.g. you could have different origins that apply to different queues, so having a global drain is confusing.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Which is why the current dispatch: boolean + drain 'event' API is slightly broken.

@ronag ronag closed this Jun 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants