我如何通过 ServicePartitionResolver 发现服务提供的端点类型?

How can I discover what kind of endpoints a service offers with ServicePartitionResolver?

我正在尝试编写一个服务解析器,我目前正在为此使用,如 https://docs.microsoft.com/en-us/azure/service-fabric/service-fabric-reliable-services-communication 中所述,ServicePartitionResolver

到目前为止,这一切都运行良好。鉴于我的服务信息,我能够解决这样的服务:

var resolvedService = await ServicePartitionResolver.GetDefault().ResolveAsync(service.ServiceName, key, CancellationToken.None);

现在,为了让我的服务能够相互通信,我正在读取第一个这样的端点地址,例如:

resolvedService.Endpoints.First().Address

这恰好 returns 我在 ICommunicationListener 实现的 OpenAsync 方法中返回的所需端点。

基本上,只要协议是 http,这一切都做得很好。

一旦我在我的 ServiceManifest.xml 服务中将协议切换为类似 tcp 的东西,请求就应该转到:

<Endpoints>
  <!-- This endpoint is used by the communication listener to obtain the port on which to 
       listen. Please note that if your service is partitioned, this port is shared with 
       replicas of different partitions that are placed in your code. -->
  <Endpoint Protocol="tcp" Name="ServiceEndpoint" Type="Input" Port="3245" />
</Endpoints>

ServiceResolver 仍然 将我的端点解析为以 http.

开头的地址

那么,现在我的问题是——我是不是做错了什么?因为对我来说,我似乎无法真正知道我正在处理的到底是什么端点。即使这没有直接反映在地址中,我仍然可以只 trim 端点字符串中的 http 部分,但也没有关于端点类型的信息。因此,从技术上讲,我可以将 http:// 替换为空白,但最好根据我从 Service Fabric 返回的内容而不是 "because I know about the endpoint".

来执行此操作

有什么想法吗?

清单中的协议定义未用于定义端点。通信侦听器实现 returns 来自 OpenAsync 的端点。所以我建议从那里开始搜索。

更多信息here and