**是grpc的新手*
正在使用nestjs。 在服务类中,我有这个:
..AService.ts
export class AService {
this.rpcService = this.grpcClient.getService<ISomeService>('SomeService');
...
public somemethod() {
this.callGrpc(stuff); <---- this does not work
}
...
public callGrpc(stuff: any): Observable<any>{
return this.rpcService.amethod({stuff})
}
}
..AController.ts
export class AController {
private readonly aService: AService
@Post('/callgrpc')
async callgrpc(@Body() genBlockDto : any) {
return await this.aService.callGrpc(stuff); <----- this works
}
}
为什么它仅在Controller类中起作用? 无论如何要在服务类中进行grpc调用?