monorepo-microservice-rbac/apps/services
2023-09-14 14:05:21 +08:00
..
alg feat: python发布消息到nats-server 2023-09-14 14:05:21 +08:00
aorta feat: antd message注入 2023-09-07 13:41:32 +08:00
cert feat: dd 2023-09-13 17:40:06 +08:00
dicom feat: label category 2023-09-12 16:19:42 +08:00
dmp feat: tasks.json编排 2023-09-07 13:12:13 +08:00
logger feat: python接入nats 2023-09-13 18:10:23 +08:00
readme.md first commit 2023-08-27 14:37:59 +08:00

发布订阅EventPattern

@MessagePattern: 基于rpc比较喜欢用一个菠萝一个坑

// 网关
@Get('/hello')
async getHello(): Promise<any> {
  const pattern = { cmd: 'sum' };
  const payload = [1, 2];
  // this.client.emit(pattern,payload)没有返回值
  const it = await this.client.send<number[]>(pattern, payload);
  return `收到返回值: ${it}`;
}

// 服务
@EventPattern({ cmd: 'sum' })
sum(data: number[]): number {
  return (data || []).reduce((a, b) => a + b);
}