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

feat: adding concurrency functionality #562

Open
wants to merge 5 commits into
base: canary
Choose a base branch
from

Conversation

nicholasgriffintn
Copy link
Member

This PR looks to add concurrency functionality.

Many users have asked for this in the past, I think this implements it in a decent way that doesn't need any external dependencies and should maintain backwards compatiblity.

There is potential that this might cause breaking issues though, so we should release this as breaking even though it might not be.

@nicholasgriffintn nicholasgriffintn requested review from a team as code owners January 28, 2025 23:35
Copy link

github-actions bot commented Jan 28, 2025

LCOV of commit e26621a during Comment PR Coverage #108

Summary coverage rate:
  lines......: 97.3% (1021 of 1049 lines)
  functions..: 100.0% (36 of 36 functions)
  branches...: no data found

Files changed coverage rate:
                   |Lines       |Functions  |Branches    
  Filename         |Rate     Num|Rate    Num|Rate     Num
  =======================================================
  src/consumer.ts  | 3.1%    678| 0.0%    21|    -      0
  src/validation.ts| 2.6%    117| 0.0%     3|    -      0

private heartbeatInterval: number;
private isPolling = false;
private stopRequestedAtTimestamp: number;
public abortController: AbortController;
private extendedAWSErrors: boolean;
private concurrency: number;
Copy link
Member Author

Choose a reason for hiding this comment

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

We may want a maxConcurrency setting that ensures we're not trying to do silly stuff.

}
waitingMessages++;
await new Promise((resolve) =>
setTimeout(resolve, this.concurrencyWaitTimeMs),
Copy link
Member Author

Choose a reason for hiding this comment

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

I need to think if concurrencyWaitTimeMs, it's probably too late and my brain is mush at this point though, but I think this conflicts with the polling timeout? Need to think on it.

try {
await this.processMessage(message);
} finally {
this.inFlightMessages--;
Copy link

Choose a reason for hiding this comment

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

It would be nice if it could poll again to maintain maximum concurrency.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants