public void SetStatus(INacosRegistration registration, string status)
        {
            ModifyInstanceHealthStatusRequest request = new ModifyInstanceHealthStatusRequest()
            {
                Ip          = registration.Host,
                Port        = registration.Port,
                ServiceName = registration.ServiceId,
                Healthy     = registration.Healthy,
                NamespaceId = registration.Namespace
            };

            _nacosClient.ModifyInstanceHealthStatusAsync(request);
        }
Exemple #2
0
        public async Task ModifyInstanceHealthStatus_Should_Succeed()
        {
            var request = new ModifyInstanceHealthStatusRequest
            {
                Ip          = "192.168.0.74",
                Port        = 9999,
                ServiceName = "testservice",
                Healthy     = false,
            };

            var res = await _namingClient.ModifyInstanceHealthStatusAsync(request);

            // 集群配置了健康检查时,该接口会返回错误
            Assert.False(res);
        }
        private async Task DeregisterAsyncInternal(INacosRegistration registration)
        {
            if (Options.IsHeartBeatEnabled && _scheduler != null)
            {
                _scheduler.Remove(registration.ServiceId);
            }

            _logger?.LogInformation("Deregistering service with consul {instanceId} ", registration.ServiceId);

            ModifyInstanceHealthStatusRequest request = new ModifyInstanceHealthStatusRequest()
            {
                Ip          = registration.Host,
                Port        = registration.Port,
                ServiceName = registration.ServiceId,
                Healthy     = registration.Healthy,
                NamespaceId = registration.Namespace
            };
            await _nacosClient.ModifyInstanceHealthStatusAsync(request);
        }