1515*/
1616
1717import { ReadWriteSplittingPlugin } from "./read_write_splitting_plugin" ;
18- import { PluginService } from "../../plugin_service" ;
1918import { WrapperProperties } from "../../wrapper_property" ;
2019import { HostInfo } from "../../host_info" ;
2120import { RdsUtils } from "../../utils/rds_utils" ;
@@ -24,29 +23,22 @@ import { Messages } from "../../utils/messages";
2423import { logger } from "../../../logutils" ;
2524import { ClientWrapper } from "../../client_wrapper" ;
2625import { equalsIgnoreCase } from "../../utils/utils" ;
27- import { FullServicesContainer } from "../../utils/full_services_container" ;
2826
2927export class GdbReadWriteSplittingPlugin extends ReadWriteSplittingPlugin {
3028 protected readonly rdsUtils : RdsUtils = new RdsUtils ( ) ;
3129
32- protected readonly restrictWriterToHomeRegion : boolean ;
33- protected readonly restrictReaderToHomeRegion : boolean ;
30+ protected restrictWriterToHomeRegion : boolean ;
31+ protected restrictReaderToHomeRegion : boolean ;
3432
3533 protected isInitialized : boolean = false ;
3634 protected homeRegion : string ;
3735
38- constructor ( serviceContainer : FullServicesContainer , properties : Map < string , any > ) {
39- super ( serviceContainer , properties ) ;
40- this . restrictWriterToHomeRegion = WrapperProperties . GDB_RW_RESTRICT_WRITER_TO_HOME_REGION . get ( properties ) ;
41- this . restrictReaderToHomeRegion = WrapperProperties . GDB_RW_RESTRICT_READER_TO_HOME_REGION . get ( properties ) ;
42- }
43-
4436 protected initSettings ( initHostInfo : HostInfo , properties : Map < string , any > ) : void {
4537 if ( this . isInitialized ) {
4638 return ;
4739 }
48-
49- this . isInitialized = true ;
40+ this . restrictWriterToHomeRegion = WrapperProperties . GDB_RW_RESTRICT_WRITER_TO_HOME_REGION . get ( properties ) ;
41+ this . restrictReaderToHomeRegion = WrapperProperties . GDB_RW_RESTRICT_READER_TO_HOME_REGION . get ( properties ) ;
5042
5143 this . homeRegion = WrapperProperties . GDB_RW_HOME_REGION . get ( properties ) ;
5244 if ( ! this . homeRegion ) {
@@ -61,6 +53,8 @@ export class GdbReadWriteSplittingPlugin extends ReadWriteSplittingPlugin {
6153 }
6254
6355 logger . debug ( Messages . get ( "GdbReadWriteSplittingPlugin.parameterValue" , "gdbRwHomeRegion" , this . homeRegion ) ) ;
56+
57+ this . isInitialized = true ;
6458 }
6559
6660 override async connect (
@@ -76,8 +70,8 @@ export class GdbReadWriteSplittingPlugin extends ReadWriteSplittingPlugin {
7670 override setWriterClient ( writerTargetClient : ClientWrapper | undefined , writerHostInfo : HostInfo ) {
7771 if (
7872 this . restrictWriterToHomeRegion &&
79- this . writerHostInfo != null &&
80- ! equalsIgnoreCase ( this . rdsUtils . getRdsRegion ( this . writerHostInfo . host ) , this . homeRegion )
73+ writerHostInfo != null &&
74+ ! equalsIgnoreCase ( this . rdsUtils . getRdsRegion ( writerHostInfo . host ) , this . homeRegion )
8175 ) {
8276 throw new ReadWriteSplittingError (
8377 Messages . get ( "GdbReadWriteSplittingPlugin.cantConnectWriterOutOfHomeRegion" , writerHostInfo . host , this . homeRegion )
0 commit comments