diff --git a/src/Connected.Data/Storage/ConnectionProvider.cs b/src/Connected.Data/Storage/ConnectionProvider.cs index 5644146..b71643d 100644 --- a/src/Connected.Data/Storage/ConnectionProvider.cs +++ b/src/Connected.Data/Storage/ConnectionProvider.cs @@ -35,7 +35,7 @@ internal sealed class ConnectionProvider : IConnectionProvider, IAsyncDisposable if (TransactionService.State == MiddlewareTransactionState.Completed) Mode = StorageConnectionMode.Isolated; - return args is ISchemaSynchronizationContext context ? ResolveSingle(context) : await ResolveMultiple(args); + return args is ISchemaSynchronizationContext context ? await ResolveSingle(context) : await ResolveMultiple(args); } /// /// This method is called if the supplied arguments already provided connection type on which they will perform operations. @@ -48,9 +48,9 @@ internal sealed class ConnectionProvider : IConnectionProvider, IAsyncDisposable /// /// /// - private ImmutableList ResolveSingle(ISchemaSynchronizationContext args) + private async Task> ResolveSingle(ISchemaSynchronizationContext args) { - return new List { EnsureConnection(args.ConnectionType, args.ConnectionString) }.ToImmutableList(); + return new List { await EnsureConnection(args.ConnectionType, args.ConnectionString) }.ToImmutableList(); } private async Task> ResolveMultiple(StorageContextArgs args) @@ -76,7 +76,7 @@ internal sealed class ConnectionProvider : IConnectionProvider, IAsyncDisposable /* * Default connection is always used regardless of sharding support */ - EnsureConnection(connectionMiddleware.ConnectionType, connectionMiddleware.DefaultConnectionString) + await EnsureConnection(connectionMiddleware.ConnectionType, connectionMiddleware.DefaultConnectionString) }; if (shardingMiddleware is not null) @@ -92,14 +92,14 @@ internal sealed class ConnectionProvider : IConnectionProvider, IAsyncDisposable if (Type.GetType(node.ConnectionType) is not Type connectionType) throw new NullReferenceException(node.ConnectionType); - result.Add(EnsureConnection(connectionType, node.ConnectionString)); + result.Add(await EnsureConnection(connectionType, node.ConnectionString)); } } return result.ToImmutableList(); } - private IStorageConnection EnsureConnection(Type connectionType, string connectionString) + private async Task EnsureConnection(Type connectionType, string connectionString) { if (Mode == StorageConnectionMode.Shared && Connections.FirstOrDefault(f => f.GetType() == connectionType @@ -108,15 +108,15 @@ internal sealed class ConnectionProvider : IConnectionProvider, IAsyncDisposable return existing; } else - return CreateConnection(connectionType, connectionString, Mode); + return await CreateConnection(connectionType, connectionString, Mode); } - private IStorageConnection CreateConnection(Type connectionType, string connectionString, StorageConnectionMode behavior) + private async Task CreateConnection(Type connectionType, string connectionString, StorageConnectionMode behavior) { if (Context.GetService(connectionType) is not IStorageConnection newConnection) throw new NullReferenceException(connectionType.Name); - newConnection.Initialize(new StorageConnectionArgs(connectionString, behavior)); + await newConnection.Initialize(new StorageConnectionArgs(connectionString, behavior)); if (behavior == StorageConnectionMode.Shared) Connections.Add(newConnection);