Ejemplo n.º 1
0
        private async Task <string> QueryListAsync(string serviceName, string clusters, int udpPort, bool healthyOnly)
        {
            var request = new ListInstancesRequest
            {
                ServiceName = serviceName,
                Clusters    = clusters,
                NamespaceId = _options.Namespace,
                UdpPort     = udpPort,
                HealthyOnly = healthyOnly,
                ClientIp    = GetCurrentIp()
            };

            var responseMessage = await _proxy.ReqApiAsync(HttpMethod.Get, RequestPathValue.INSTANCE_LIST, null, request.ToDict(), _options.DefaultTimeOut).ConfigureAwait(false);

            responseMessage.EnsureSuccessStatusCode();

            return(await responseMessage.Content.ReadAsStringAsync().ConfigureAwait(false));
        }
Ejemplo n.º 2
0
        public async Task <ListInstancesResult> ListInstancesAsync(ListInstancesRequest request)
        {
            if (request == null)
            {
                throw new NacosException(NacosException.CLIENT_INVALID_PARAM, "request param invalid");
            }

            request.CheckParam();

            var responseMessage = await _proxy.ReqApiAsync(HttpMethod.Get, RequestPathValue.INSTANCE_LIST, null, request.ToDict(), _options.DefaultTimeOut);

            switch (responseMessage.StatusCode)
            {
            case System.Net.HttpStatusCode.OK:
                var result = await responseMessage.Content.ReadAsStringAsync();

                var obj = result.ToObj <ListInstancesResult>();
                return(obj);

            default:
                _logger.LogWarning($"[client.ListInstances] Query instance list of service failed {responseMessage.StatusCode.ToString()}");
                throw new NacosException((int)responseMessage.StatusCode, $"Query instance list of service failed {responseMessage.StatusCode.ToString()}");
            }
        }