@@ -45,7 +45,95 @@ import { TelemetryFactory } from "./utils/telemetry/telemetry_factory";
4545import { DriverDialect } from "./driver_dialect/driver_dialect" ;
4646import { AllowedAndBlockedHosts } from "./AllowedAndBlockedHosts" ;
4747
48- export class PluginService implements ErrorHandler , HostListProviderService {
48+ export interface PluginService extends ErrorHandler {
49+ isInTransaction ( ) : boolean ;
50+
51+ setInTransaction ( inTransaction : boolean ) : void ;
52+
53+ getHostListProvider ( ) : HostListProvider | null ;
54+
55+ getInitialConnectionHostInfo ( ) : HostInfo | null ;
56+
57+ setHostListProvider ( hostListProvider : HostListProvider ) : void ;
58+
59+ setInitialConnectionHostInfo ( initialConnectionHostInfo : HostInfo ) : void ;
60+
61+ getHostInfoByStrategy ( role : HostRole , strategy : string , hosts ?: HostInfo [ ] ) : HostInfo | undefined ;
62+
63+ getCurrentHostInfo ( ) : HostInfo | null ;
64+
65+ setCurrentHostInfo ( value : HostInfo ) : void ;
66+
67+ getCurrentClient ( ) : AwsClient ;
68+
69+ getConnectionUrlParser ( ) : ConnectionUrlParser ;
70+
71+ getProperties ( ) : Map < string , any > ;
72+
73+ getDialect ( ) : DatabaseDialect ;
74+
75+ getDriverDialect ( ) : DriverDialect ;
76+
77+ getHostInfoBuilder ( ) : HostInfoBuilder ;
78+
79+ isStaticHostListProvider ( ) : boolean ;
80+
81+ acceptsStrategy ( role : HostRole , strategy : string ) : boolean ;
82+
83+ forceRefreshHostList ( ) : Promise < void > ;
84+
85+ forceRefreshHostList ( targetClient : ClientWrapper ) : Promise < void > ;
86+
87+ forceRefreshHostList ( targetClient ?: ClientWrapper ) : Promise < void > ;
88+
89+ forceMonitoringRefresh ( shouldVerifyWriter : boolean , timeoutMs : number ) : Promise < boolean > ;
90+
91+ refreshHostList ( ) : Promise < void > ;
92+
93+ refreshHostList ( targetClient : ClientWrapper ) : Promise < void > ;
94+
95+ refreshHostList ( targetClient ?: ClientWrapper ) : Promise < void > ;
96+
97+ getAllHosts ( ) : HostInfo [ ] ;
98+
99+ getHosts ( ) : HostInfo [ ] ;
100+
101+ setAvailability ( hostAliases : Set < string > , availability : HostAvailability ) : void ;
102+
103+ updateConfigWithProperties ( props : Map < string , any > ) : void ;
104+
105+ fillAliases ( targetClient : ClientWrapper , hostInfo : HostInfo ) : Promise < void > ;
106+
107+ identifyConnection ( targetClient : ClientWrapper ) : Promise < HostInfo | null > ;
108+
109+ connect ( hostInfo : HostInfo , props : Map < string , any > ) : Promise < ClientWrapper > ;
110+
111+ forceConnect ( hostInfo : HostInfo , props : Map < string , any > ) : Promise < ClientWrapper > ;
112+
113+ setCurrentClient ( newClient : ClientWrapper , hostInfo : HostInfo ) : Promise < Set < HostChangeOptions > > ;
114+
115+ isClientValid ( targetClient : ClientWrapper ) : Promise < boolean > ;
116+
117+ abortCurrentClient ( ) : Promise < void > ;
118+
119+ abortTargetClient ( targetClient : ClientWrapper | undefined | null ) : Promise < void > ;
120+
121+ getSessionStateService ( ) : SessionStateService ;
122+
123+ updateState ( sql : string ) : Promise < void > ;
124+
125+ updateInTransaction ( sql : string ) : void ;
126+
127+ updateDialect ( targetClient : ClientWrapper ) : Promise < void > ;
128+
129+ getHostRole ( client : any ) : Promise < HostRole > | undefined ;
130+
131+ getTelemetryFactory ( ) : TelemetryFactory ;
132+
133+ setAllowedAndBlockedHosts ( allowedAndBlockedHosts : AllowedAndBlockedHosts ) : void ;
134+ }
135+
136+ export class PluginServiceImpl implements PluginService , HostListProviderService {
49137 private static readonly DEFAULT_HOST_AVAILABILITY_CACHE_EXPIRE_NANO = 5 * 60_000_000_000 ; // 5 minutes
50138 private readonly _currentClient : AwsClient ;
51139 private _currentHostInfo ?: HostInfo ;
@@ -154,6 +242,10 @@ export class PluginService implements ErrorHandler, HostListProviderService {
154242 this . _currentHostInfo = value ;
155243 }
156244
245+ getProperties ( ) : Map < string , any > {
246+ return this . props ;
247+ }
248+
157249 getCurrentClient ( ) : AwsClient {
158250 return this . _currentClient ;
159251 }
@@ -234,7 +326,7 @@ export class PluginService implements ErrorHandler, HostListProviderService {
234326
235327 private updateHostAvailability ( hosts : HostInfo [ ] ) {
236328 hosts . forEach ( ( host ) => {
237- const availability = PluginService . hostAvailabilityExpiringCache . get ( host . url ) ;
329+ const availability = PluginServiceImpl . hostAvailabilityExpiringCache . get ( host . url ) ;
238330 if ( availability != null ) {
239331 host . availability = availability ;
240332 }
@@ -352,7 +444,7 @@ export class PluginService implements ErrorHandler, HostListProviderService {
352444 const changes = new Map < string , Set < HostChangeOptions > > ( ) ;
353445 for ( const host of hostsToChange ) {
354446 const currentAvailability = host . getAvailability ( ) ;
355- PluginService . hostAvailabilityExpiringCache . put ( host . url , availability , PluginService . DEFAULT_HOST_AVAILABILITY_CACHE_EXPIRE_NANO ) ;
447+ PluginServiceImpl . hostAvailabilityExpiringCache . put ( host . url , availability , PluginServiceImpl . DEFAULT_HOST_AVAILABILITY_CACHE_EXPIRE_NANO ) ;
356448 if ( currentAvailability !== availability ) {
357449 let hostChanges = new Set < HostChangeOptions > ( ) ;
358450 if ( availability === HostAvailability . AVAILABLE ) {
@@ -606,6 +698,6 @@ export class PluginService implements ErrorHandler, HostListProviderService {
606698 }
607699
608700 static clearHostAvailabilityCache ( ) : void {
609- PluginService . hostAvailabilityExpiringCache . clear ( ) ;
701+ PluginServiceImpl . hostAvailabilityExpiringCache . clear ( ) ;
610702 }
611703}
0 commit comments