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

Create a service for a common http interface #720

Merged
merged 5 commits into from
Sep 5, 2023
Merged

Conversation

a3957273
Copy link
Member

@a3957273 a3957273 commented Sep 3, 2023

In our default implementation it's not particularly useful, but does allow us a central place to add in deployment specific configuration for network communication.

// This function has the same syntax as 'https.Agent', but is centralised throughout
// the application in case it needs to be altered.
export function getHttpsAgent(config?: https.AgentOptions) {
return new https.Agent({ ...config })
Copy link
Member

Choose a reason for hiding this comment

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

Do we want to create a new agent on every call to this function or should we be reusing a single agent?

Could do something like:

// Not sure what the correct type is off the top of my head
let httpsAgent: HttpsAgent | undefined

export function getHttpsAgent(config?: https.AgentOptions) {
  if (!httpsAgent) {
    httpsAgent = new https.Agent({ ...config })
  }
  return httpsAgent
}

@a3957273 a3957273 merged commit e1d8b45 into main Sep 5, 2023
@a3957273 a3957273 deleted the chore/common-http-agent branch September 5, 2023 12:38
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