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

enabling ProxyAgent take an instance of Agent as an option #1998

Closed
wants to merge 2 commits into from

Conversation

RishabhKodes
Copy link
Contributor

In the updated constructor, the opts parameter is checked to see if it contains an agent property that is an instance of Agent. If it is, then the [kAgent] is set to the provided instance. Otherwise, a new Agent instance is created and assigned to the [kAgent].

fixes: #1962

Signed-off-by: Rishabh Bhandari <[email protected]>
@KhafraDev
Copy link
Member

Can you add in a test?

@codecov-commenter
Copy link

codecov-commenter commented Mar 9, 2023

Codecov Report

Patch coverage: 100.00% and no project coverage change.

Comparison is base (3606c35) 90.45% compared to head (d31d7ae) 90.45%.

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #1998   +/-   ##
=======================================
  Coverage   90.45%   90.45%           
=======================================
  Files          71       71           
  Lines        6138     6138           
=======================================
  Hits         5552     5552           
  Misses        586      586           
Impacted Files Coverage Δ
lib/proxy-agent.js 93.50% <100.00%> (ø)

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

☔ View full report in Codecov by Sentry.
📢 Do you have feedback about the report comment? Let us know in this issue.

Signed-off-by: Rishabh Bhandari <[email protected]>
@RishabhKodes
Copy link
Contributor Author

Can you add in a test?

Added the tests for both scenarios, take a look.

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

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

Could you add docs for this change?

@ronag
Copy link
Member

ronag commented Mar 11, 2023

How is this different from #2003

@RishabhKodes
Copy link
Contributor Author

RishabhKodes commented Mar 11, 2023

How is this different from #2003

#2003 majorly targets the broader issue of successive requests to ProxyAgent getting blocked, thus introducing a new Client for solving the issue. This pr also does somewhat of the same thing enabling the user to create an instance of Agent (similar but less complex than creating a Client) inside the ProxyAgent.

This pr solves the inability to use ProxyAgent and any other Agent at the same time (example mentioned here, #1957).

@ronag
Copy link
Member

ronag commented Mar 11, 2023

Do you think we could use the same pattern with a factory?

@RishabhKodes
Copy link
Contributor Author

Closing this as #2003 solves the issue in almost the same way (and that solution has been approved)

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.

Make ProxyAgent take another Agent as an option
5 participants