1export class ClientContainer { 2 // private _credentials: rpc.ChannelCredentials | undefined; 3 // private _clients: { service: any, client?: rpc.Client, target: any }[] = []; 4 private _port: string | number | undefined; 5 private _host: string | undefined; 6 7 /* get clients(): { service: any; client?: rpc.Client; target: any }[] { 8 return this._clients; 9 } 10 11 set clients(value: { service: any; client?: rpc.Client; target: any }[]) { 12 this._clients = value; 13 }*/ 14 15 /* get credentials(): rpc.ChannelCredentials | undefined { 16 return this._credentials; 17 } 18 19 set credentials(value: rpc.ChannelCredentials | undefined) { 20 this._credentials = value; 21 }*/ 22 23 get port(): string | number | undefined { 24 return this._port; 25 } 26 27 set port(value: string | number | undefined) { 28 this._port = value; 29 } 30 31 get host(): string | undefined { 32 return this._host; 33 } 34 35 set host(value: string | undefined) { 36 this._host = value; 37 } 38 39 public registryClient(target: any, path: string) { 40 // let packageDefinition = proto_load.loadSync(path, { 41 // keepCase: true, 42 // longs: String, 43 // enums: String, 44 // defaults: true, 45 // oneofs: true 46 // }); 47 // let protoDescriptor = rpc.loadPackageDefinition(packageDefinition); 48 // 49 // const packages = Object.keys(protoDescriptor); 50 // for (let packageKey of packages) { 51 // for (let key in protoDescriptor[packageKey]) { 52 // 53 // } 54 // } 55 }; 56 57 public start() { 58 this.loadSettings(); 59 this._registryClient(); 60 } 61 62 private loadSettings() { 63 let { host, port} = SettingRegistry.settings; 64 this._host = host; 65 this._port = port; 66 } 67 68 private _registryClient() { 69 // for (let clientContainer of this._clients) { 70 // let client: rpc.Client = new clientContainer.service( 71 // `${this.host}:${this.port}`, 72 // this.credentials 73 // ); 74 // clientContainer.client = client; 75 // } 76 } 77} 78 79 80export class SettingRegistry { 81 static settings: Settings; 82 83 static registry(settings: Settings) { 84 this.settings = settings; 85 } 86} 87 88export interface Settings { 89 port: string | number; 90 91 host?: string; 92}