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

Refactor BaseConnectionPool empty method #585

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

bandinib-amzn
Copy link
Member

@bandinib-amzn bandinib-amzn commented Aug 12, 2023

Description

ConnectionPool.empty() never calls callback when there is no connection. Refactor empty method so that callback will get always called.

Issues Resolved

List any issues this PR will resolve, e.g. Closes [...].

Check List

  • New functionality includes testing.
    • All tests pass
  • Linter check was successfull - yarn run lint doesn't show any errors
  • Commits are signed per the DCO using --signoff
  • Changelog was updated.

By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin and signing off your commits, please check here.

@dblock
Copy link
Member

dblock commented Aug 14, 2023

Looks good, needs a test please.

@bandinib-amzn bandinib-amzn force-pushed the baseconnectionpool-empty branch 2 times, most recently from d79eb8b to 79efb7c Compare August 14, 2023 21:29
Signed-off-by: Bandini Bhopi <bandinib@amazon.com>
@bandinib-amzn
Copy link
Member Author

Looks good, needs a test please.

Added UT with no connection.

@@ -18,6 +18,7 @@ Inspired from [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
- Bumps `eslint-config-prettier` from 8.8.0 to 9.0.0
### Changed
- Make handling of long numerals an option that is disabled by default ([#557](https://github.com/opensearch-project/opensearch-js/pull/557))
- Refactor BaseConnectionPool empty method so that callback will always get called even when there is no connection ([#585](https://github.com/opensearch-project/opensearch-js/pull/585))
Copy link
Member

Choose a reason for hiding this comment

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

I think this is really a bug fix, the callback should be called when there's no connections. So I would move this to fixes and say "Fix: ensure connection pool callback with no connections"

pool.empty();
t.equal(pool.size, 0);
t.end();
});
Copy link
Member

Choose a reason for hiding this comment

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

Can we add a test that ensures the callback is called, too?

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