Esempio n. 1
0
        public NamingGrpcClientProxy(
            ILogger logger,
            string namespaceId,
            SecurityProxy securityProxy,
            IServerListFactory serverListFactory,
            NacosSdkOptions options,
            ServiceInfoHolder serviceInfoHolder)
        {
            this._logger        = logger;
            this.namespaceId    = namespaceId;
            this.uuid           = Guid.NewGuid().ToString();
            this._options       = options;
            this._securityProxy = securityProxy;

            this.requestTimeout = options.DefaultTimeOut > 0 ? options.DefaultTimeOut : 3000L;

            Dictionary <string, string> labels = new Dictionary <string, string>()
            {
                { RemoteConstants.LABEL_SOURCE, RemoteConstants.LABEL_SOURCE_SDK },
                { RemoteConstants.LABEL_MODULE, RemoteConstants.LABEL_MODULE_NAMING },
            };

            this.rpcClient = RpcClientFactory.CreateClient(uuid, RemoteConnectionType.GRPC, labels);

            this.namingGrpcConnectionEventListener = new NamingGrpcConnectionEventListener(_logger, this);

            Start(serverListFactory, serviceInfoHolder);
        }
Esempio n. 2
0
File: Rpc.cs Progetto: Sholtee/rpc
            static async Task Invoke()
            {
                using var factory = new RpcClientFactory(Host);
                IModule proxy = await factory.CreateClient <IModule>();

                Assert.That(proxy.Add(1, 2), Is.EqualTo(3));
            }
Esempio n. 3
0
        public async Task InstalledService_ShouldRun() 
        {
            if (Environment.OSVersion.Platform != PlatformID.Win32NT) Assert.Ignore("The related feature is Windows exclusive.");

            using var factory = new RpcClientFactory(HOST);
            ICalculator calculator = await factory.CreateClient<ICalculator>();

            Assert.That(await calculator.AddAsync(1, 1), Is.EqualTo(2));
        }
Esempio n. 4
0
            static async Task Invoke()
            {
                using var factory = new RpcClientFactory(Host)
                      {
                          Timeout = TimeSpan.FromSeconds(5)
                      };

                ICalculator proxy = await factory.CreateClient <ICalculator>();

                Assert.That(proxy.Add(1, 2), Is.EqualTo(3));
            }
Esempio n. 5
0
        private RpcClient EnsureRpcClient(string taskId)
        {
            Dictionary <string, string> labels    = GetLabels();
            Dictionary <string, string> newlabels = new Dictionary <string, string>(labels);

            newlabels["taskId"] = taskId;

            RpcClient rpcClient = RpcClientFactory
                                  .CreateClient("config-" + taskId + "-" + uuid, RemoteConnectionType.GRPC, newlabels);

            if (rpcClient.IsWaitInited())
            {
                InitHandlerRpcClient(rpcClient);
                rpcClient.SetTenant(GetTenant());
                rpcClient.SetClientAbilities(InitAbilities());
                rpcClient.Start();
            }

            return(rpcClient);
        }