Azure IoT 中心的 RegistryManager 和服务客户​​端——是否是单例?

Azure IoT Hub's RegistryManager and Service Client - singletons or not?

IoT 中心服务 SDK 的 RegistryManager (and ServiceClient) 应该用作单例(HttpClient 模式)还是 using var registryManager = ... 首选?

更多

查看 RegistryManager 的 source code it creates its own non-static instance of HttpClientHelper,它创建了自己的 HttpClient 非静态实例,这看起来像一个反模式。这表明 RegistryManager 的一个实例是首选,看一下它的代码,我认为多个用户应该没问题。

然而,我无法找到一份文档,其中说明 RegistryManager 的一个实例应该用作整个应用程序的单例。

现已记录在案

    /// This client creates lifetime long instances of <see cref="HttpClient"/> that are tied to the URI of the
    /// IoT hub specified, configure any proxy settings, and connection lease timeout.
    /// For that reason, the instances are not static and an application using this client
    /// should create and save it for all use. Repeated creation may cause
    /// <see href="https://docs.microsoft.com/azure/architecture/antipatterns/improper-instantiation/">socket exhaustion</see>.

https://github.com/Azure/azure-iot-sdk-csharp/pull/2423