@@ -2,6 +2,7 @@ import { makeConnection } from "../connection";
22import { Authenticator } from "../auth" ;
33import { Context , ConnectionOptions , FireboltClientOptions } from "../types" ;
44import { ResourceManager } from "../service" ;
5+ import { NodeHttpClient } from "../http/node" ;
56
67export class FireboltCore {
78 private options : FireboltClientOptions ;
@@ -14,21 +15,39 @@ export class FireboltCore {
1415 }
1516
1617 async connect ( connectionOptions : ConnectionOptions ) {
17- const auth = new Authenticator ( this . context , connectionOptions ) ;
18- const connection = makeConnection ( this . context , connectionOptions ) ;
18+ // Create a new httpClient instance for each connection
19+ const httpClient = new NodeHttpClient ( ) ;
20+
21+ // Create a new context with the new httpClient
22+ const connectionContext = {
23+ ...this . context ,
24+ httpClient
25+ } ;
26+
27+ const auth = new Authenticator ( connectionContext , connectionOptions ) ;
28+ const connection = makeConnection ( connectionContext , connectionOptions ) ;
1929 await auth . authenticate ( ) ;
2030 await connection . resolveEngineEndpoint ( ) ;
21- const context = {
31+ const resourceContext = {
2232 connection,
23- ...this . context
33+ ...connectionContext
2434 } ;
25- this . resourceManager = new ResourceManager ( context ) ;
35+ this . resourceManager = new ResourceManager ( resourceContext ) ;
2636 return connection ;
2737 }
2838
2939 async testConnection ( connectionOptions : ConnectionOptions ) {
30- const auth = new Authenticator ( this . context , connectionOptions ) ;
31- const connection = makeConnection ( this . context , connectionOptions ) ;
40+ // Create a new httpClient instance for test connection too
41+ const httpClient = new NodeHttpClient ( ) ;
42+
43+ // Create a new context with the new httpClient
44+ const connectionContext = {
45+ ...this . context ,
46+ httpClient
47+ } ;
48+
49+ const auth = new Authenticator ( connectionContext , connectionOptions ) ;
50+ const connection = makeConnection ( connectionContext , connectionOptions ) ;
3251 await auth . authenticate ( ) ;
3352 await connection . resolveEngineEndpoint ( ) ;
3453 await connection . testConnection ( ) ;
0 commit comments