mirror of
https://github.com/OutlineFoundation/outline-server.git
synced 2026-09-01 06:40:37 +00:00
refactor(server): use a reusable http.Agent (#1644)
This commit is contained in:
parent
47f24520d3
commit
15a9e54e5e
1 changed files with 7 additions and 2 deletions
|
|
@ -102,12 +102,17 @@ export interface PrometheusClient {
|
|||
}
|
||||
|
||||
export class ApiPrometheusClient implements PrometheusClient {
|
||||
constructor(private address: string) {}
|
||||
private readonly agent: http.Agent;
|
||||
|
||||
constructor(private address: string) {
|
||||
this.agent = new http.Agent({ keepAlive: true });
|
||||
}
|
||||
|
||||
private request(url: string): Promise<QueryResultData> {
|
||||
return new Promise<QueryResultData>((fulfill, reject) => {
|
||||
const options = {agent: this.agent};
|
||||
http
|
||||
.get(url, (response) => {
|
||||
.get(url, options, (response) => {
|
||||
if (response.statusCode < 200 || response.statusCode > 299) {
|
||||
reject(new Error(`Got error ${response.statusCode}`));
|
||||
response.resume();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue