Nestjs:如何从客户端处理微服务MessagePattern

时间:2020-04-10 10:50:59

标签: microservices nestjs nats.io

 @MessagePattern({ service: 'data', slot: 'authorizeUser'})
  @UseFilters(new ExceptionFilter())
  authorizeUser(@Payload() payload: Types.IMessagePayload) {
    return this.appService.authorizeUser(payload);
  }

在我打电话之前,我想检查MessagePattern的存在,因为当模式不存在时,应用正在挂起

 await this.clientProxy
      .send({ service: 'data', slot: 'findAndPopulate' }, payload)
      .toPromise();

我可以为每个模式设置他的网关,并使用@ nestjs / terminus从客户端检查他的存在,但是我认为这不是一个很好的解决方案

@Get('/getSpecificUser/health')
@MessagePattern({ service: 'data', slot: 'getSpecificUser ' })
authorizeUser(@Payload() payload: Types.IMessagePayload) {
   return this.appService.authorizeUser(payload);
}


  // client
_this.health.check([() => _this.dns.pingCheck('group','/getSpecificUser/health')]);

有其他更好的解决方案吗?

0 个答案:

没有答案