public async static Task <ServiceInformation> FindServiceInstanceAsync(this IClusterProvider self, string serviceName) { var res = await self.FindServiceInstancesAsync(serviceName); if (res.Length == 0) { throw new Exception("Could not find service"); } return(res[ThreadLocalRandom.Current.Next(0, res.Length - 1)]); }
public static async Task <ServiceInformation> FindServiceInstanceAsync(this IClusterProvider self, string serviceName) { var res = await self.FindServiceInstancesAsync(serviceName).ConfigureAwait(false); if (res.Length == 0) { throw new Exception("没有发现该服务"); } var i = serviceindex % res.Count(); var serviceinfo = res[i]; if (i >= long.MaxValue) { i = long.MinValue; } Interlocked.Increment(ref serviceindex); return(serviceinfo); }
public static Task <ServiceInformation[]> FindServiceInstancesAsync(string name) { return(_clusterProvider.FindServiceInstancesAsync(name)); }