protected async Task <Dictionary <string, IGetOperation> > MultiGetCore(IEnumerable <KeyValuePair <string, ulong> > items) { var ops = new Dictionary <string, IGetOperation>(); var tasks = new List <Task>(); var known = new HashSet <string>(); using (var ad = new AggregateDisposable()) { foreach (var item in items) { var key = item.Key; if (!known.Add(key)) { continue; } try { var op = opFactory.Get(ad.Add(keyTransformer.Transform(key)), item.Value); tasks.Add(cluster.Execute(op)); ops[key] = op; } catch (IOException e) { tasks.Add(Task.FromResult(new GetOperationResult().FailWith(e))); } } await Task.WhenAll(tasks).ConfigureAwait(false); } return(ops); }
public static IDisposable Start() { DateTimeOffset start = DateTimeOffset.Now; var logger = LazyContainer.Value.Resolve <ILogger>(); var ret = new AggregateDisposable(); try { var configurationProvider = LazyContainer.Value.Resolve <INodeConfigurationProvider>(); var configurations = configurationProvider.GetConfigurationAsync().GetAwaiter().GetResult().ToList(); if (configurations.Count == 0) { throw new InvalidOperationException("No listeners are configured!"); } foreach (var configuration in configurations) { if (configuration.Urls.Count == 0) { logger.Info($"Starting listener {configuration.ServerFactory ?? "default"} on port: {configuration.Port}"); } else { logger.Info($"Starting listener {configuration.ServerFactory ?? "default"} with URLs: {string.Join(", ", configuration.Urls)}"); } ret.Add(WebApp.Start <Startup>(configuration)); } } catch (Exception ex) { var message = $"Startup failed: {ex.Message}"; logger.Fatal(message, ex); throw new Exception("Startup Failed", ex); } logger.Info($"Startup took: {DateTimeOffset.Now - start}"); return(ret); }