static void Main(string[] args) { var host = "8.8.8.8"; var ping = new Ping(); var isAlive = ping.IsAlive(host); Console.WriteLine(host + " alive: " + isAlive); }
public async void CommandTest() { var balancer = LoadBalancerBuilder.NewBuilder() .WithPing(Ping) .WithRule(new Thrifty.MicroServices.Ribbon.Rules.RoundRobinRule()).Build("demo", 1 * 1000); balancer.AddServers(Servers); var command = new LoadBalancerCommand(balancer, null, null, null); var x = await command.Submit(s => Task.FromResult(Ping.IsAlive(s))); Assert.True(x); }
public async void WeightedResponseTimeRuleTest() { var collector = new DefaultServerStatusCollector(); var accumulater = new DefaultServerWeightAccumulater(collector); var rule = new Thrifty.MicroServices.Ribbon.Rules.WeightedResponseTimeRule(accumulater); var balancer = new BaseLoadBalancer(1 * 1000, "demo", rule, Ping, new SerialPingStrategy(), LoggerFactory); accumulater.LoadBalancer = balancer; balancer.AddServers(Servers); var command = new LoadBalancerCommand(balancer, null, null, null); const int count = 1000; var index = 0; while (index++ < count) { Assert.True(await command.Submit(server => Task.FromResult(Ping.IsAlive(server)))); } }