Beispiel #1
0
        private List <string> QueryServiceURLs(string consulServiceURL, string serviceName, string tags = "")
        {
            List <string> strs = new List <string>();

            if (!string.IsNullOrEmpty(consulServiceURL))
            {
                ServiceEntry[] result = ConsulClientSDK.AvaliableServices(consulServiceURL, serviceName, tags).Result;
                if ((result == null ? false : (int)result.Length > 0))
                {
                    ServiceEntry[] serviceEntryArray = result;
                    for (int i = 0; i < (int)serviceEntryArray.Length; i++)
                    {
                        ServiceEntry serviceEntry = serviceEntryArray[i];
                        string       empty        = string.Empty;
                        empty = (string.IsNullOrEmpty(serviceEntry.Service.Address) ? serviceEntry.Node.Address : serviceEntry.Service.Address);
                        strs.Add(string.Format("http://{0}:{1}/", empty, serviceEntry.Service.Port));
                    }
                }
            }
            return(strs);
        }
Beispiel #2
0
 private bool DeregisterService(string serviceName)
 {
     return(ConsulClientSDK.DeregisterService(ConsulConfigurator.Instance.ConsulAgentUrl, serviceName).Result);
 }
Beispiel #3
0
        private bool RegisterService(string serviceName, string tags, string serviceAddress, int servicePort, string healthCheckAddress = "", int healthCheckInterval = 60)
        {
            bool result = ConsulClientSDK.RegsterService(ConsulConfigurator.Instance.ConsulAgentUrl, serviceName, tags, serviceAddress, servicePort, healthCheckInterval, healthCheckAddress, string.Empty).Result;

            return(result);
        }