public void TestTryGetBatchMode() { var dic = new Dictionary <string, object>(); SignalRUtils.TryGetBatchMode( dic, out string batchConfigMode, out int batchWaitMilliSeconds, out SignalREnums.BatchMode mode); Assert.Equal(batchConfigMode, SignalRConstants.DefaultBatchMode); }
public async Task BatchConnect( IDictionary <string, object> stepParameters, IDictionary <string, object> pluginParameters, IList <IHubConnectionAdapter> connections, int concurrentConnection) { SignalRUtils.TryGetBatchMode( stepParameters, out string batchConfigMode, out int batchWaitMilliSeconds, out SignalREnums.BatchMode mode); var packages = (from i in Enumerable.Range(0, connections.Count()) where connections[i].GetStat() == SignalREnums.ConnectionInternalStat.Init select(Connection: connections[i], LocalIndex: i)).ToList(); // 100 milliseconds is the default fine-granularity var period = SignalRConstants.RateLimitDefaultGranularity; var factor = 1000 / period; var fillTokenPerDuration = concurrentConnection > factor ? concurrentConnection / factor : 1; switch (mode) { case SignalREnums.BatchMode.ExtLimitRatePress: await Util.ExternalRateLimitBatchProcess(packages, SignalRUtils.StartConnect, concurrentConnection, fillTokenPerDuration, period); break; case SignalREnums.BatchMode.LimitRatePress: await Util.RateLimitBatchProces(packages, SignalRUtils.StartConnect, concurrentConnection, fillTokenPerDuration, period); break; case SignalREnums.BatchMode.HighPress: await Util.BatchProcess(packages, SignalRUtils.StartConnect, concurrentConnection); break; case SignalREnums.BatchMode.LowPress: await Util.LowPressBatchProcess(packages, SignalRUtils.StartConnect, concurrentConnection, batchWaitMilliSeconds); break; } }