diff --git a/Samples/Sample.ConsoleApp/WorkDistribution/Example.cs b/Samples/Sample.ConsoleApp/WorkDistribution/Example.cs index 18fd4992..353674c7 100644 --- a/Samples/Sample.ConsoleApp/WorkDistribution/Example.cs +++ b/Samples/Sample.ConsoleApp/WorkDistribution/Example.cs @@ -17,11 +17,14 @@ public static class Example public static async Task Perform() { var postgresStore = new PostgreSqlFunctionStore("Server=localhost;Database=rfunctions;User Id=postgres;Password=Pa55word!; Include Error Detail=true;"); - await postgresStore.DropIfExists(); + await postgresStore.Initialize(); + await postgresStore.TruncateTables(); var sqlServerStore = new SqlServerFunctionStore("Server=localhost;Database=rfunctions;User Id=sa;Password=Pa55word!;Encrypt=True;TrustServerCertificate=True;Max Pool Size=200;"); - await sqlServerStore.DropIfExists(); + await sqlServerStore.Initialize(); + await sqlServerStore.TruncateTables(); var mySqlStore = new MySqlFunctionStore("server=localhost;userid=root;password=Pa55word!;database=rfunctions;AllowPublicKeyRetrieval=True;"); - await mySqlStore.DropIfExists(); + await mySqlStore.Initialize(); + await mySqlStore.TruncateTables(); Console.WriteLine(); Console.WriteLine("Postgres: "); diff --git a/Samples/Sample.OrderProcessing/Program.cs b/Samples/Sample.OrderProcessing/Program.cs index fbc7491b..94eaac86 100644 --- a/Samples/Sample.OrderProcessing/Program.cs +++ b/Samples/Sample.OrderProcessing/Program.cs @@ -15,8 +15,8 @@ public static async Task Main(string[] args) var connStr = "Server=localhost;Database=rfunctions;User Id=postgres;Password=Pa55word!; Include Error Detail=true;"; var store = new PostgreSqlFunctionStore(connStr); - await store.DropIfExists(); await store.Initialize(); + await store.TruncateTables(); var functionsRegistry = new FunctionsRegistry( store, new Settings( diff --git a/Stores/MySQL/Cleipnir.ResilientFunctions.MySQL.Tests/Sql.cs b/Stores/MySQL/Cleipnir.ResilientFunctions.MySQL.Tests/Sql.cs index 0b6aeb93..bebc04c9 100644 --- a/Stores/MySQL/Cleipnir.ResilientFunctions.MySQL.Tests/Sql.cs +++ b/Stores/MySQL/Cleipnir.ResilientFunctions.MySQL.Tests/Sql.cs @@ -48,8 +48,8 @@ public static void AssemblyInit(TestContext testContext) private static async Task CreateAndInitializeStore(string testClass, string testMethod) { var store = new MySqlFunctionStore(ConnectionString); - await store.DropIfExists(); await store.Initialize(); + await store.TruncateTables(); return store; } diff --git a/Stores/MySQL/Cleipnir.ResilientFunctions.MySQL/MySqlFunctionStore.cs b/Stores/MySQL/Cleipnir.ResilientFunctions.MySQL/MySqlFunctionStore.cs index 887e455c..bd61f517 100644 --- a/Stores/MySQL/Cleipnir.ResilientFunctions.MySQL/MySqlFunctionStore.cs +++ b/Stores/MySQL/Cleipnir.ResilientFunctions.MySQL/MySqlFunctionStore.cs @@ -78,19 +78,6 @@ PRIMARY KEY (type, instance), await command.ExecuteNonQueryAsync(); } - private string? _dropIfExistsSql; - public async Task DropIfExists() - { - await _messageStore.DropUnderlyingTable(); - await _mySqlUnderlyingRegister.DropUnderlyingTable(); - await _timeoutStore.DropUnderlyingTable(); - - await using var conn = await CreateOpenConnection(_connectionString); - _dropIfExistsSql ??= $"DROP TABLE IF EXISTS {_tablePrefix}"; - await using var command = new MySqlCommand(_dropIfExistsSql, conn); - await command.ExecuteNonQueryAsync(); - } - private string? _truncateTablesSql; public async Task TruncateTables() { diff --git a/Stores/PostgreSQL/Cleipnir.ResilientFunctions.PostgreSQL.Tests/Sql.cs b/Stores/PostgreSQL/Cleipnir.ResilientFunctions.PostgreSQL.Tests/Sql.cs index acd85202..8f44fe2c 100644 --- a/Stores/PostgreSQL/Cleipnir.ResilientFunctions.PostgreSQL.Tests/Sql.cs +++ b/Stores/PostgreSQL/Cleipnir.ResilientFunctions.PostgreSQL.Tests/Sql.cs @@ -43,7 +43,7 @@ private static async Task CreateAndInitializeStore(stri { var store = new PostgreSqlFunctionStore(ConnectionString); await store.Initialize(); - await store.TruncateTable(); + await store.TruncateTables(); return store; } diff --git a/Stores/PostgreSQL/Cleipnir.ResilientFunctions.PostgreSQL/PostgreSqlFunctionStore.cs b/Stores/PostgreSQL/Cleipnir.ResilientFunctions.PostgreSQL/PostgreSqlFunctionStore.cs index 35037824..058c8474 100644 --- a/Stores/PostgreSQL/Cleipnir.ResilientFunctions.PostgreSQL/PostgreSqlFunctionStore.cs +++ b/Stores/PostgreSQL/Cleipnir.ResilientFunctions.PostgreSQL/PostgreSqlFunctionStore.cs @@ -98,22 +98,9 @@ CREATE INDEX IF NOT EXISTS idx_{_tablePrefix}_succeeded await using var command = new NpgsqlCommand(_initializeSql, conn); await command.ExecuteNonQueryAsync(); } - - private string? _dropIfExistsSql; - public async Task DropIfExists() - { - await _postgresSqlUnderlyingRegister.DropUnderlyingTable(); - await _messageStore.DropUnderlyingTable(); - await _timeoutStore.DropUnderlyingTable(); - - await using var conn = await CreateConnection(); - _dropIfExistsSql ??= $"DROP TABLE IF EXISTS {_tablePrefix}"; - await using var command = new NpgsqlCommand(_dropIfExistsSql, conn); - await command.ExecuteNonQueryAsync(); - } - + private string? _truncateTableSql; - public async Task TruncateTable() + public async Task TruncateTables() { await _messageStore.TruncateTable(); await _timeoutStore.Truncate(); diff --git a/Stores/SqlServer/Cleipnir.ResilientFunctions.SqlServer.Tests/Sql.cs b/Stores/SqlServer/Cleipnir.ResilientFunctions.SqlServer.Tests/Sql.cs index 0536df19..1f9c217e 100644 --- a/Stores/SqlServer/Cleipnir.ResilientFunctions.SqlServer.Tests/Sql.cs +++ b/Stores/SqlServer/Cleipnir.ResilientFunctions.SqlServer.Tests/Sql.cs @@ -39,8 +39,8 @@ public static void AssemblyInit(TestContext testContext) private static async Task CreateAndInitializeStore(string testClass, string testMethod) { var store = new SqlServerFunctionStore(ConnectionString);//, tablePrefix: ComputeSha256Hash(testClass + "ยง" + testMethod)); - await store.DropIfExists(); await store.Initialize(); + await store.TruncateTables(); return store; } diff --git a/Stores/SqlServer/Cleipnir.ResilientFunctions.SqlServer/SqlServerFunctionStore.cs b/Stores/SqlServer/Cleipnir.ResilientFunctions.SqlServer/SqlServerFunctionStore.cs index 9062c874..b55c59fe 100644 --- a/Stores/SqlServer/Cleipnir.ResilientFunctions.SqlServer/SqlServerFunctionStore.cs +++ b/Stores/SqlServer/Cleipnir.ResilientFunctions.SqlServer/SqlServerFunctionStore.cs @@ -99,21 +99,8 @@ CREATE INDEX {_tablePrefix}_idx_Succeeded } catch (SqlException exception) when (exception.Number == 2714) {} } - private string? _dropIfExistsSql; - public async Task DropIfExists() - { - await _underlyingRegister.DropUnderlyingTable(); - await _messageStore.DropUnderlyingTable(); - await _timeoutStore.DropUnderlyingTable(); - - await using var conn = await _connFunc(); - _dropIfExistsSql ??= $"DROP TABLE IF EXISTS {_tablePrefix}"; - await using var command = new SqlCommand(_dropIfExistsSql, conn); - await command.ExecuteNonQueryAsync(); - } - private string? _truncateSql; - public async Task Truncate() + public async Task TruncateTables() { await _underlyingRegister.TruncateTable(); await _messageStore.TruncateTable(); diff --git a/Stores/StressTests/Engines/PostgreSqlEngine.cs b/Stores/StressTests/Engines/PostgreSqlEngine.cs index e421da97..cc12323e 100644 --- a/Stores/StressTests/Engines/PostgreSqlEngine.cs +++ b/Stores/StressTests/Engines/PostgreSqlEngine.cs @@ -19,7 +19,7 @@ public async Task InitializeDatabaseAndInitializeAndTruncateTable() var store = new PostgreSqlFunctionStore(ConnectionString); await store.Initialize(); - await store.TruncateTable(); + await store.TruncateTables(); } public async Task NumberOfNonCompleted() diff --git a/Stores/StressTests/Engines/SqlServerEngine.cs b/Stores/StressTests/Engines/SqlServerEngine.cs index 14ddf512..9caf7386 100644 --- a/Stores/StressTests/Engines/SqlServerEngine.cs +++ b/Stores/StressTests/Engines/SqlServerEngine.cs @@ -18,7 +18,7 @@ public async Task InitializeDatabaseAndInitializeAndTruncateTable() var store = new SqlServerFunctionStore(ConnectionString); await store.Initialize(); - await store.Truncate(); + await store.TruncateTables(); } public async Task NumberOfNonCompleted()