@@ -74,6 +74,10 @@ const sqlCacheCapacity = 30;
7474export class HttpClient implements Client {
7575 #client: hrana . HttpClient ;
7676 protocol : "http" ;
77+ #url: URL ;
78+ #intMode: IntMode ;
79+ #customFetch: Function | undefined ;
80+ #concurrency: number ;
7781 #authToken: string | undefined ;
7882 #promiseLimitFunction: ReturnType < typeof promiseLimit < any > > ;
7983
@@ -85,11 +89,20 @@ export class HttpClient implements Client {
8589 customFetch : Function | undefined ,
8690 concurrency : number ,
8791 ) {
88- this . #client = hrana . openHttp ( url , authToken , customFetch ) ;
89- this . #client. intMode = intMode ;
90- this . protocol = "http" ;
92+ this . #url = url ;
9193 this . #authToken = authToken ;
92- this . #promiseLimitFunction = promiseLimit < any > ( concurrency ) ;
94+ this . #intMode = intMode ;
95+ this . #customFetch = customFetch ;
96+ this . #concurrency = concurrency ;
97+
98+ this . #client = hrana . openHttp (
99+ this . #url,
100+ this . #authToken,
101+ this . #customFetch,
102+ ) ;
103+ this . #client. intMode = this . #intMode;
104+ this . protocol = "http" ;
105+ this . #promiseLimitFunction = promiseLimit < any > ( this . #concurrency) ;
93106 }
94107
95108 private async limit < T > ( fn : ( ) => Promise < T > ) : Promise < T > {
@@ -267,6 +280,23 @@ export class HttpClient implements Client {
267280 this . #client. close ( ) ;
268281 }
269282
283+ async reconnect ( ) : Promise < void > {
284+ try {
285+ if ( ! this . closed ) {
286+ // Abort in-flight ops and free resources
287+ this . #client. close ( ) ;
288+ }
289+ } finally {
290+ // Recreate the underlying hrana client
291+ this . #client = hrana . openHttp (
292+ this . #url,
293+ this . #authToken,
294+ this . #customFetch,
295+ ) ;
296+ this . #client. intMode = this . #intMode;
297+ }
298+ }
299+
270300 get closed ( ) : boolean {
271301 return this . #client. closed ;
272302 }
0 commit comments