public async Task RunAsync(IApplicationArgs args) { foreach (var options in _options.Databases) { await RunAsync(options, args); } }
public Task RunAsync(IApplicationArgs args) { foreach (var options in _options.Databases) { _logger.LogDebug($"validating options for database {options?.Database.Id}"); options.Validate(); _logger.LogDebug("options are valid"); } return(Task.FromResult(true)); }
public async Task RunAsync(IApplicationArgs args) { var strategiesToRun = _strategies .Where(p => p.IsApplicable(args)) .OrderBy(o => o.Order); foreach (var strategy in strategiesToRun) { await strategy.RunAsync(args); } }
private async Task RunAsync(ClientContextOptions options, IApplicationArgs args) { options.Validate(); var context = _factory.Create(options); if (context is CosmosSqlApiClientContext sqlApiClientContext) { if (args.CreateDatabase) { _logger.LogInformation($"creating database {options.Database.Id}"); await sqlApiClientContext.CreateDatabaseIfNotExistsAsync(options.Database.Id, options.Database.Throughput); } if (args.CreateContainers) { _logger.LogInformation("creating containers"); var containerTasks = options .Database.Containers .Select(container => sqlApiClientContext.CreateContainerIfNotExistsAsync(container.Id, container.PartitionKey)); await Task.WhenAll(containerTasks); } } else if (context is CosmosTableApiClientContext tableApiClientContext) { if (args.CreateContainers) { _logger.LogInformation("creating tables"); var tableTasks = options .Database.Containers .Select(table => tableApiClientContext.CreateTableIfNotExistsAsync(table.Id, table.Throughput)); await Task.WhenAll(tableTasks); } } else { throw new NotSupportedException($"no valid client context could be found to perform this operation"); } }
public bool IsApplicable(IApplicationArgs args) { return(args.CreateDatabase || args.CreateContainers); }
public bool IsApplicable(IApplicationArgs args) { return(args.OnlyValidate); }