NestJS - 使用服务发现在微服务之间进行通信

问题描述 投票:0回答:0

我有 2 个 dockerized

NestJS
应用程序需要使用 HTTP 协议相互通信。

一种方式是使用HttpModule向远程微服务发送http请求。但是有了这个,应用程序需要知道远程微服务的 IP(确切的 url)。

  1. 所以我想使用一些服务发现解决方案——kubernetes 内置了服务发现机制,但找不到很多关于如何使用 kubernetes 实现这一点的例子。
  2. 然后我在 nestjs 中发现了客户端代理,可以使用它的名称来引用远程服务?
  3. 我们可以在 http 案例中使用 ClientProxy 吗?我也认为 NestJS 文档说的有点令人困惑
    In Nest, a microservice is fundamentally an application that uses a different transport layer than HTTP. 
    HTTP 是一个应用层协议,使用 TCP 作为第 4 层协议。
http kubernetes nestjs microservices service-discovery
© www.soinside.com 2019 - 2024. All rights reserved.