Skip to content

Conversation

@mcollina
Copy link
Member

Summary

  • Add getUpstream(upstream) method to BalancedPool class that returns the Pool instance for a given upstream URL
  • Enable users to retrieve specific Pool instances for debugging, monitoring, or direct Pool operations
  • Comprehensive test coverage following TDD approach with TypeScript definitions

Changes

  • lib/dispatcher/balanced-pool.js: Implement getUpstream() method that finds and returns Pool for upstream
  • test/node-test/balanced-pool.js: Add comprehensive test suite covering valid/invalid upstreams and error cases
  • types/balanced-pool.d.ts: Add TypeScript method definition with proper typing
  • test/types/balanced-pool.test-d.ts: Add TypeScript tests to verify type definitions

Test Coverage

  • ✅ Returns correct Pool instance for valid upstream URLs
  • ✅ Handles non-existent upstreams appropriately
  • ✅ Validates input parameters correctly
  • ✅ TypeScript definitions work as expected
  • ✅ All existing tests continue to pass
  • ✅ No linting errors

Use Cases

This enhancement allows developers to:

  • Debug specific Pool connections for an upstream
  • Monitor individual Pool statistics and health
  • Perform direct operations on a specific Pool instance
  • Introspect BalancedPool internal state for troubleshooting

The method follows existing BalancedPool patterns and maintains backward compatibility.

Add getUpstream(upstream) method that returns the Pool instance
for a given upstream URL. This allows users to retrieve specific
Pool instances for debugging, monitoring, or direct operations.

- Implement getUpstream() method in BalancedPool class
- Add comprehensive test coverage with TDD approach
- Include TypeScript definitions and type tests
- All tests pass with no lint errors

Signed-off-by: Matteo Collina <hello@matteocollina.com>
@mcollina mcollina requested a review from Uzlopak September 24, 2025 13:22
@Uzlopak Uzlopak requested a review from Copilot September 24, 2025 17:00
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds a new getUpstream() method to the BalancedPool class that allows retrieval of specific Pool instances for given upstream URLs. This enables users to access individual Pool instances for debugging, monitoring, and direct operations.

  • Add getUpstream() method to BalancedPool class for retrieving specific Pool instances
  • Add comprehensive test coverage for valid/invalid upstreams and edge cases
  • Add TypeScript definitions and type tests for the new method

Reviewed Changes

Copilot reviewed 3 out of 4 changed files in this pull request and generated 1 comment.

File Description
lib/dispatcher/balanced-pool.js Implements the getUpstream() method that finds and returns Pool instances by upstream URL
test/node-test/balanced-pool.js Adds comprehensive test suite covering valid upstreams, non-existent upstreams, and destroyed pools
test/types/balanced-pool.test-d.ts Adds TypeScript type tests to verify proper typing of the new method

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link
Contributor

@Uzlopak Uzlopak left a comment

Choose a reason for hiding this comment

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

LGTM

@mcollina mcollina merged commit f2f3281 into main Sep 24, 2025
28 of 29 checks passed
@mcollina mcollina deleted the feature/balanced-pool-get-upstream branch September 24, 2025 17:07
@github-actions github-actions bot mentioned this pull request Jan 5, 2026
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.

3 participants