1- import type { ServerUnaryCall } from '@grpc/grpc-js' ;
2- import { Metadata } from '@grpc/grpc-js' ;
1+ import type { ServerUnaryCall , Metadata } from '@grpc/grpc-js' ;
32import { Controller } from '@nestjs/common' ;
43
54import { ApiConfigService } from '../../../../src/shared/services/api-config.service' ;
@@ -16,22 +15,25 @@ export class ServiceRegistryGrpcController implements ServiceRegistryGrpcControl
1615 private readonly apiConfig : ApiConfigService ,
1716 ) { }
1817
19- async registerService ( {
20- heartbeatDurationInSec,
21- type,
22- url,
23- region,
24- } : registerServiceRequest ) : Promise < registerServiceResponse > {
18+ async registerService (
19+ request : registerServiceRequest ,
20+ _metadata : Metadata ,
21+ call : ServerUnaryCall < registerServiceRequest , registerServiceResponse > ,
22+ ) : Promise < registerServiceResponse > {
2523 try {
24+ const { heartbeatDurationInSec, type, region } = request ;
25+
2626 const serviceTypeKey = ServiceTypeEnum [ type ] ;
2727
2828 if ( ! serviceTypeKey || ! ( serviceTypeKey in ServiceType ) ) {
2929 throw new Error ( `Invalid service type: ${ type } ` ) ;
3030 }
3131
32+ const callerIp = call . getPeer ( ) ;
33+
3234 const { token } = await this . serviceRegistryService . register ( {
3335 heartbeatDurationInSec,
34- url,
36+ url : callerIp ,
3537 type : ServiceType [ serviceTypeKey as keyof typeof ServiceType ] ,
3638 region,
3739 } ) ;
0 commit comments