public LeadershipWeightModifier(ILeaderResultDetector resultDetector, ILog log) { if (resultDetector == null) { throw new ArgumentNullException(nameof(resultDetector)); } this.resultDetector = resultDetector; this.log = log ?? new SilentLog(); }
public void SetUp() { replica = new Uri("http://replica"); replicas = new List <Uri> { replica }; request = Request.Get("foo/bar"); response = new Response(ResponseCode.Ok); result = new ReplicaResult(replica, response, ResponseVerdict.Accept, TimeSpan.Zero); weight = 1.0; resultDetector = Substitute.For <ILeaderResultDetector>(); storageProvider = Substitute.For <IReplicaStorageProvider>(); storageProvider.Obtain <bool>(Arg.Any <string>()).Returns(storage = new ConcurrentDictionary <Uri, bool>()); modifier = new LeadershipWeightModifier(resultDetector, new ConsoleLog()); }
/// <summary> /// Adds a <see cref="LeadershipWeightModifier"/> with given <paramref name="leaderResultDetector"/> to the chain. /// </summary> public static void AddLeadershipModifier(this IWeighedReplicaOrderingBuilder builder, ILeaderResultDetector leaderResultDetector) => builder.AddModifier(new LeadershipWeightModifier(leaderResultDetector, builder.Log));