private async Task CreateContainerIfNotExistsAsync(CosmosContainerOptions options) { // TODO: Container単位のDefaultThroughputの実装 CosmosContainer container = await Database.Containers.CreateContainerIfNotExistsAsync(options.ToCosmosContainerSettings()); var throughput = await container.ReadProvisionedThroughputAsync(); _logger.LogInformation($"Container:{container.Id}; throughput:{ConvertThroughputLogString(throughput)}"); }
private async Task CreateContainerIfNotExistsAsync(CosmosContainerOptions options) { // TODO: Container単位のDefaultThroughputの実装 Container container = await Database.CreateContainerIfNotExistsAsync(options.ToContainerProperties()); var throughputResponse = await container.ReadThroughputAsync(); _logger.LogInformation($"Container:{container.Id}; throughput:{ConvertThroughputLogString(throughputResponse?.Resource?.Throughput)}"); }
public CosmosContainer(CosmosContainerOptions <T> options, ILoggerFactory loggerFactory) { _options = options ?? throw new ArgumentNullException(nameof(options)); _logger = loggerFactory.CreateLogger <CosmosContainer <T> >() ?? throw new ArgumentNullException(nameof(loggerFactory)); ValidateOptions(options); _containerProvider = CosmosContainerProvider.CreateFromOptions(options); }
public static IServiceCollection AddCosmosRepository <T>(this IServiceCollection collection, Action <CosmosContainerOptions <T>, IConfiguration> configurationFactory) where T : class, IEntity { collection.AddSingleton(sp => { var options = new CosmosContainerOptions <T>(); var configuration = sp.GetRequiredService <IConfiguration>(); configurationFactory(options, configuration); return(options); }); collection.AddSingleton <IRepositoryFactory <T>, CosmosContainerRepositoryFactory <T> >(); collection.AddSingleton <IRepository <T> >(sp => sp.GetRequiredService <IRepositoryFactory <T> >().Create()); return(collection); }